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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ETreePainting solver = new ETreePainting();
        solver.solve(1, in, out);
        out.close();
    }

    static class ETreePainting {
        static ETreePainting.Node[] graph;
        static int n;

        static void dfs(int a, int par) {
            for (Map.Entry<Integer, ETreePainting.Pair> p : graph[a].edges.entrySet()) {
                if (p.getKey() != par) {
                    dfs(p.getKey(), a);
                    graph[a].tot += graph[p.getKey()].tot + 1;
                    p.getValue().childs = graph[p.getKey()].tot + 1;
                }
            }
            if (par != -1) {
                graph[a].edges.get(par).childs = n - graph[a].tot - 1;
            }
        }

        static long calc(int a, int par) {
            long toret = n;
            if (graph[a].visited && par != -1) {
                toret = graph[a].sum - graph[a].edges.get(par).dp;
                if (graph[a].edges.get(graph[a].last).dp != 0) {
                    toret += graph[a].edges.get(graph[a].last).dp;
                } else {
                    long x = calc(graph[a].last, a);
                    graph[a].edges.get(graph[a].last).dp = x;
                    toret += x;
                }
                toret += n - graph[a].edges.get(par).childs;
                return toret;
            }
            if (par != -1) {
                toret -= graph[a].edges.get(par).childs;
            }
            long s = 0;
            for (Map.Entry<Integer, ETreePainting.Pair> p : graph[a].edges.entrySet()) {
                if (p.getKey() != par) {
                    if (p.getValue().dp != 0) {
                        toret += p.getValue().dp;
                        s += p.getValue().dp;
                    } else {
                        long x = calc(p.getKey(), a);
                        p.getValue().dp = x;
                        toret += x;
                        s += x;
                    }
                }
            }
            if (par != -1) {
                graph[a].visited = true;
                graph[a].sum = s;
                graph[a].last = par;
            }
            return toret;
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            n = sc.nextInt();
            graph = new ETreePainting.Node[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new ETreePainting.Node();
                graph[i].edges = new HashMap<>();
            }
            int x, y;
            for (int i = 0; i < n - 1; i++) {
                x = sc.nextInt() - 1;
                y = sc.nextInt() - 1;
                graph[x].edges.put(y, new ETreePainting.Pair(0, 0));
                graph[y].edges.put(x, new ETreePainting.Pair(0, 0));
            }
            dfs(0, -1);
            ArrayList<Integer> leafs = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if (graph[i].edges.size() == 1) {
                    leafs.add(i);
                }
            }
            long ans = 0;
            for (int i = 0; i < leafs.size(); i++) {
                ans = Math.max(ans, calc(leafs.get(i), -1));
            }
            out.println(ans);
        }

        static class Node {
            HashMap<Integer, ETreePainting.Pair> edges;
            int tot;
            boolean visited;
            long sum;
            int last;

        }

        static class Pair {
            int childs;
            long dp;

            public Pair(int a, long b) {
                childs = a;
                dp = b;
            }

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}

