You are given a tree (an undirected connected acyclic graph) consisting of n vertices. You are playing a game on this tree.

Initially all vertices are white. On the first turn of the game you choose one vertex and paint it black. Then on each turn you choose a white vertex adjacent (connected by an edge) to any black vertex and paint it black.

Each time when you choose a vertex (even during the first turn), you gain the number of points equal to the size of the connected component consisting only of white vertices that contains the chosen vertex. The game ends when all vertices are painted black.

Let's see the following example:

<image>

Vertices 1 and 4 are painted black already. If you choose the vertex 2, you will gain 4 points for the connected component consisting of vertices 2, 3, 5 and 6. If you choose the vertex 9, you will gain 3 points for the connected component consisting of vertices 7, 8 and 9.

Your task is to maximize the number of points you gain.

Input

The first line contains an integer n — the number of vertices in the tree (2 ≤ n ≤ 2 ⋅ 10^5).

Each of the next n - 1 lines describes an edge of the tree. Edge i is denoted by two integers u_i and v_i, the indices of vertices it connects (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i).

It is guaranteed that the given edges form a tree.

Output

Print one integer — the maximum number of points you gain if you will play optimally.

Examples

Input


9
1 2
2 3
2 5
2 6
1 4
4 9
9 7
9 8


Output


36


Input


5
1 2
1 3
2 4
2 5


Output


14

Note

The first example tree is shown in the problem statement.
//package ContestEd67;

import javafx.util.Pair;

import java.io.*;
import java.util.*;

public class mainE {
    public static PrintWriter out = new PrintWriter(System.out);
    public static FastScanner enter = new FastScanner(System.in);

    public static void main(String[] args) throws IOException {
        int n=enter.nextInt();
        Graph g=new Graph(n);
        for (int i = 0; i <n-1 ; i++) {
            int a=enter.nextInt();
            int b=enter.nextInt();
            g.add(a,b);
            g.add(b,a);
        }
        g.solve();
    }

    //and others on mccme

    static class Graph {
        int n; //vertex
        int m; //edges
        LinkedList<Integer>[] vert; //adjacency list
        //ArrayList<Pair<Integer, Integer>> edge; //edges in graph
        HashMap<Pair<Integer,Integer>,Long> ed;
        boolean used[]; //massives for veteces
        long[] dp;
        int kol_vo[];
        static class pair{
            int u,w;
            public pair(int u, int w) {
                this.u = u;
                this.w = w;
            }
        }

        public Graph(int n) {
            this.n = n;
            vert = new LinkedList[n + 1]; //1 ,...., n
            for (int i = 1; i < n + 1; i++) vert[i] = new LinkedList<>();
            used = new boolean[n + 1];
            ed=new HashMap<>();
            dp=new long[n+1];
            kol_vo=new int[n+1];
        }

        public Graph(int n, int m) {
            this.n = n;
            vert = new LinkedList[n + 1]; //1 ,...., n
            for (int i = 1; i < n + 1; i++) vert[i] = new LinkedList<>();
            //edge = new ArrayList<>(); //0 ,...., m-1
            used = new boolean[n + 1];
        }

        public void add(int a, int b) {
            vert[a].addLast(b);
            /*if (edge != null) {
                edge.add(new Pair<>(a, b));
            }*/
        }
        public void add(int a, int b, long w) {
            vert[a].addLast(b);
            /*if (edge != null) {
                edge.add(new Pair<>(a, b));
            }*/
            ed.put(new Pair(a,b),w);
        }

        public void solve(){
            //Без ограничения общности подвесим за 1
            DFS(1);
            //System.out.println(Arrays.toString(kol_vo));
            for (int i = 1; i <n+1 ; i++) {
                dp[1]+=kol_vo[i];
            }
            DFS2(1);
            //System.out.println(Arrays.toString(dp));
            long max=0;
            for (int i = 1; i <n+1 ; i++) {
                max=Math.max(max,dp[i]);
            }
            System.out.println(max);
        }
        void DFSUtil2(int v, boolean was[]) {
            was[v] = true;
            Iterator<Integer> i = vert[v].listIterator();
            while (i.hasNext()) {
                int n = i.next();
                if (!was[n]) {
                    dp[n]=dp[v]+this.n-2*kol_vo[n];
                    DFSUtil2(n, was);
                }
            }
        }

        void DFS2(int v) {
            boolean was[] = new boolean[n + 1];
            DFSUtil2(v, was);
        }

        void DFSUtil(int v, boolean was[]) {
            was[v] = true;
            if(v!=1 && vert[v].size()==1) {
                kol_vo[v]=1;
                return;
            }
            Iterator<Integer> i = vert[v].listIterator();
            int summ=0;
            while (i.hasNext()) {
                int n = i.next();
                if (!was[n]) {
                    DFSUtil(n, was);
                    summ+=kol_vo[n];
                }
            }
            kol_vo[v]=summ+1;
        }

        void DFS(int v) {
            boolean was[] = new boolean[n + 1];
            DFSUtil(v, was);
        }

        public void cout_tree() {
            for (int i = 1; i < n + 1; i++) {
                out.println(i + " ");
                out.println(vert[i]);
            }
        }


    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer stok;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() throws IOException {
            while (stok == null || !stok.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return null;
                }
                stok = new StringTokenizer(s);
            }
            return stok.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        char nextChar() throws IOException {
            return (char) (br.read());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }
    }
}

