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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        new Solver().solve();
    }

    static class Solver {
        StringBuilder sb = new StringBuilder();
        Scanner reader = new Scanner(System.in);
        int clc = 0;
        //Reader reader = new Reader();

        void solve() throws IOException {
            int n = reader.nextInt();
            Tree tree = new Tree(n);
            while(n --> 1)
                tree.add(reader.nextInt() - 1, reader.nextInt() - 1);
            tree.calcDp(0, 0);
            tree.solve(0, 0);
            write(tree.ans);
            System.out.println(sb);
        }


        class Tree extends Graph {
            int[] dp;
            public long clc = 0, ans = 0;

            public Tree(int size) {
                super(size);
                dp = new int[size];
            }

            int calcDp(int tec, int p) {
                dp[tec] = 1;
                for(Vertex vertex : getVertexes()[tec].getNeighbours()) {
                    if(vertex.getIdx() == p) continue;
                    dp[tec] += calcDp(vertex.getIdx(), tec);
                }
                clc += dp[tec];
                return dp[tec];
            }

            void solve(int tec, int p) {
                if(clc > ans) ans = clc;
                for(Vertex vertex : getVertexes()[tec].getNeighbours()) {
                    if(vertex.getIdx() == p) continue;
                    clc += getSize() - 2 * dp[vertex.getIdx()];
                    solve(vertex.getIdx(), tec);
                    clc -= getSize() - 2 * dp[vertex.getIdx()];
                }
            }
        }

        class Graph {
            private Vertex[] vertexes;
            private int size;

            class Vertex {
                private int idx;
                private List<Main.Solver.Graph.Vertex> neighbours;
                Vertex(int idx) {
                    this.idx = idx;
                    neighbours = new ArrayList<>();
                }

                public int getIdx() {
                    return idx;
                }

                public void setIdx(int idx) {
                    this.idx = idx;
                }

                public List<Main.Solver.Graph.Vertex> getNeighbours() {
                    return neighbours;
                }
            }

            Graph(int size) {
                this.size = size;
                vertexes = new Main.Solver.Graph.Vertex[size];
                for(int i = 0; i < size; ++ i)
                    vertexes[i] = new Main.Solver.Graph.Vertex(i);
            }

            public void add(int a, int b) {
                vertexes[a].getNeighbours().add(vertexes[b]);
                vertexes[b].getNeighbours().add(vertexes[a]);
            }

            public int getSize() {
                return size;
            }

            public Vertex[] getVertexes() {
                return vertexes;
            }
        }

        <T> void write(T ...objects) {
            for(int i = 0; i < objects.length; ++ i)
                sb.append(objects[i]).append(' ');
        }

        <T> void writeln(T ...objects) {
            if(objects.length == 0) sb.append('\n');
            for(T object : objects)
                sb.append(object).append('\n');
        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;private DataInputStream din;private byte[] buffer;private int bufferPointer, bytesRead;
        public Reader(){din=new DataInputStream(System.in);buffer=new byte[BUFFER_SIZE];bufferPointer=bytesRead=0;
        }public Reader(String file_name) throws IOException {din=new DataInputStream(new FileInputStream(file_name));buffer=new byte[BUFFER_SIZE];bufferPointer=bytesRead=0;
        }public String readLine() throws IOException{byte[] buf=new byte[64];int cnt=0,c;while((c=read())!=-1){if(c=='\n')break;buf[cnt++]=(byte)c;}return new String(buf,0,cnt);
        }public int nextInt() throws IOException{int ret=0;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c=read();do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(neg)return -ret;return ret;
        }public long nextLong() throws IOException{long ret=0;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c=read();do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(neg)return -ret;return ret;
        }public double nextDouble() throws IOException{double ret=0,div=1;byte c=read();while(c<=' ')c=read();boolean neg=(c=='-');if(neg)c = read();do {ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');if(c=='.')while((c=read())>='0'&&c<='9')ret+=(c-'0')/(div*=10);if(neg)return -ret;return ret;
        }private void fillBuffer() throws IOException{bytesRead=din.read(buffer,bufferPointer=0,BUFFER_SIZE);if(bytesRead==-1)buffer[0]=-1;
        }private byte read() throws IOException{if(bufferPointer==bytesRead)fillBuffer();return buffer[bufferPointer++];
        }public void close() throws IOException{if(din==null) return;din.close();}
    }
}