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.
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class E1187 {
    static class Scanner {
        BufferedReader br;
        StringTokenizer tk = new StringTokenizer("");

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

        public int nextInt() throws IOException {
            if (tk.hasMoreTokens())
                return Integer.parseInt(tk.nextToken());
            tk = new StringTokenizer(br.readLine());
            return nextInt();
        }

        public long nextLong() throws IOException {
            if (tk.hasMoreTokens())
                return Long.parseLong(tk.nextToken());
            tk = new StringTokenizer(br.readLine());
            return nextLong();
        }

        public String next() throws IOException {
            if (tk.hasMoreTokens())
                return (tk.nextToken());
            tk = new StringTokenizer(br.readLine());
            return next();
        }

        public String nextLine() throws IOException {
            tk = new StringTokenizer("");
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            if (tk.hasMoreTokens())
                return Double.parseDouble(tk.nextToken());
            tk = new StringTokenizer(br.readLine());
            return nextDouble();
        }

        public char nextChar() throws IOException {
            if (tk.hasMoreTokens())
                return (tk.nextToken().charAt(0));
            tk = new StringTokenizer(br.readLine());
            return nextChar();
        }

        public int[] nextIntArray(int n) throws IOException {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public int[] nextIntArrayOneBased(int n) throws IOException {
            int a[] = new int[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArrayOneBased(int n) throws IOException {
            long a[] = new long[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextLong();
            return a;
        }


    }

    public static void main(String args[]) throws IOException {
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }
    static int n;
    static ArrayList<Integer> g[];
    static int subTreeSize[];
    static long dpSubtree[];
    static long dpFinal[];
    static void solve() throws IOException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n=in.nextInt();
        g=new ArrayList[n+1];
        subTreeSize=new int[n+1];
        dpFinal=new long[n+1];
        dpSubtree=new long[n+1];
        for(int i=0;i<=n;i++)
            g[i]=new ArrayList<>();
        for(int i=1;i<n;i++){
            int u=in.nextInt();
            int v=in.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        dfs1(1, 0);
        out.println(dfs2(1,0));
        out.close();

    }
    //calculate dpSubtree and subtreeSize
    static long dfs1(int nd, int p){
        subTreeSize[nd]=1;
        for(int x:g[nd]){
            if(x!=p){
                dpSubtree[nd]+=dfs1(x,nd);
                subTreeSize[nd]+=subTreeSize[x];
            }

        }
        dpSubtree[nd]+=subTreeSize[nd];
        return dpSubtree[nd];
    }

    static long dfs2(int nd, int p){
        long ans=dpSubtree[nd]-subTreeSize[nd]+n;
        //find max value attainable if the blacking starts at some node in the subtree of this node
        long childrenSubtreeDpSum=dpSubtree[nd]-subTreeSize[nd];
        for(int x:g[nd]){
            //compute the answer if blacking starts in some node in subtreee of x
            if(x!=p){
                ans=Math.max(ans, dfs2(x,nd)+n-subTreeSize[x]+childrenSubtreeDpSum-dpSubtree[x]);
            }
        }
        return ans;
    }
}
