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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andy Phan
 */
public class e {
    static ArrayList<Integer>[] edges;
    static int n;
    static int[] par;
    static long[] down;
    static long[] up;
    static long[] size;
    public static void main(String[] args) {
        FS in = new FS(System.in);
        n = in.nextInt();
        edges = new ArrayList[n];
        for(int i = 0; i < n; i++) edges[i] = new ArrayList<>();
        for(int i = 1; i < n; i++) {
            int u = in.nextInt()-1;
            int v = in.nextInt()-1;
            edges[u].add(v);
            edges[v].add(u);
        }
        long max = 0;
        par = new int[n];
        down = new long[n];
        up = new long[n];
        size = new long[n];
        Arrays.fill(par, -1);
        Arrays.fill(down, -1);
        Arrays.fill(up, -1);
        Arrays.fill(size, -1);
        for(int i = 0; i < n; i++) {
            max = Math.max(max, n+sumDown(i)+sumUp(i));
        }
        System.out.println(max);
    }
    
    static long size(int node) {
        if(size[node] != -1) return size[node];
        size[node] = 1;
        for(int a : edges[node]) {
            if(a == par[node]) continue;
            if(par[a] == -1) par[a] = node;
            size[node] += size(a);
        }
        return size[node];
    }
    
    static long sumDown(int node) {
        if(down[node] != -1) return down[node];
        down[node] = 0;
        for(int a : edges[node]) {
            if(a == par[node]) continue;
            if(par[a] == -1) par[a] = node;
            down[node] += sumDown(a);
            down[node] += size(a);
        }
        return down[node];
    }
    
    static long sumUp(int node) {
        if(up[node] != -1) return up[node];
        up[node] = 0;
        if(par[node] != -1) {
            up[node] = sumUp(par[node])+sumDown(par[node])-sumDown(node)+n-2*size(node);
        }
        return up[node];
    }
    
    static class FS {
        BufferedReader in;
        StringTokenizer token;
        
        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }
        
        public String next() {
            if(token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
