#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
const int maxn = 2e5;
int n, u, v;
int head[maxn + 5], sz[maxn + 5];
long long dp1[maxn + 5], dp2[maxn + 5];
struct edge {
  int to, _next;
} G[2 * maxn + 5];
int num = 0;
void add(int u, int v) {
  G[++num].to = v;
  G[num]._next = head[u];
  head[u] = num;
}
void dfs1(int u, int fa) {
  sz[u] = 1;
  dp1[u] = 1;
  for (int i = head[u]; i; i = G[i]._next) {
    int v = G[i].to;
    if (v == fa) continue;
    dfs1(v, u);
    sz[u] += sz[v];
    dp1[u] += dp1[v] + sz[v];
  }
}
void dfs2(int u, int fa) {
  if (u == 1)
    dp2[u] = 0;
  else {
    long long tem = dp1[fa] - dp1[u] - sz[u];
    dp2[u] = n - sz[u] + tem + dp2[fa];
  }
  for (int i = head[u]; i; i = G[i]._next) {
    int v = G[i].to;
    if (v == fa) continue;
    dfs2(v, u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; i++)
    if (dp1[i] + dp2[i] > ans) ans = dp1[i] + dp2[i];
  printf("%I64d\n", ans);
  return 0;
}
