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.
#include <bits/stdc++.h>
const double pi = acos(-1.0);
using namespace std;
inline long long MAX2(long long a, long long b) {
  return (a) > (b) ? (a) : (b);
}
inline long long MAX3(long long a, long long b, long long c) {
  return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long MIN2(long long a, long long b) {
  return (a) < (b) ? (a) : (b);
}
inline long long MIN3(long long a, long long b, long long c) {
  return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));
}
int mod = 1e9 + 7;
int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {
  if (!a) {
    x = 0;
    y = 1;
    return b;
  }
  int64_t x1, y1;
  int64_t d = extGcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
inline long long addmod(long long a, long long b) {
  a = a % mod + b % mod;
  if (a > mod) a %= mod;
  return a;
}
inline long long submod(long long a, long long b) {
  a = a % mod - b % mod;
  if (a < 0) a += mod;
  return a;
}
inline long long mulmod(long long a, long long b) {
  return (a % mod * b % mod) % mod;
}
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
inline long long exp(long long a, long long b) {
  if (a == 0) return 0ll;
  long long r = 1LL;
  while (b > 0) {
    if (b & 1) {
      r = r * (a % mod);
      r = (r + mod) % mod;
    }
    b /= 2;
    a = (a % mod) * (a % mod);
    a = (a + mod) % mod;
  }
  return (r + mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  if (a == 0) return b;
  return gcd(b, a % b);
}
unsigned long int setbits(long long n) {
  unsigned long int count = 0;
  while (n) {
    n &= (n - 1);
    count++;
  }
  return count;
}
vector<int> adj[200005];
long long dp[200005];
long long sz[200005];
long long ans = 0;
long long dfs(int src, int par) {
  int curr = 1;
  for (auto child : adj[src]) {
    if (child != par) curr += dfs(child, src);
  }
  return sz[src] = curr;
}
void solve(int src, int par) {
  long long child_contrib = 0;
  for (auto child : adj[src]) {
    if (child != par) {
      solve(child, src);
    }
  }
  for (auto child : adj[src]) {
    child_contrib += dp[child];
  }
  dp[src] = child_contrib + sz[src];
}
void dfs2(int src, int par) {
  ans = MAX2(ans, dp[src]);
  for (auto child : adj[src]) {
    if (child == par) continue;
    dp[src] -= dp[child];
    dp[src] -= sz[child];
    sz[src] -= sz[child];
    dp[child] += sz[src];
    dp[child] += dp[src];
    sz[child] += sz[src];
    dfs2(child, src);
    dp[child] -= dp[src];
    dp[child] -= sz[src];
    sz[child] -= sz[src];
    sz[src] += sz[child];
    dp[src] += dp[child];
    dp[src] += sz[child];
  }
}
int main() {
  if (fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int ss, ee;
    cin >> ss >> ee;
    adj[ss].push_back(ee);
    adj[ee].push_back(ss);
  }
  dfs(1, 0);
  solve(1, 0);
  dfs2(1, 0);
  cout << ans << '\n';
}
