#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, sz[maxn];
int head[maxn], cnt;
long long dp[maxn][2], ans;
struct edge {
  int to, next;
} e[maxn << 1];
void adde(int u, int v) {
  e[++cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt;
}
void dfs1(int u, int fa) {
  sz[u] = 1;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs1(v, u);
    sz[u] += sz[v];
    dp[u][0] += dp[v][0];
  }
  dp[u][0] += sz[u];
}
void dfs2(int u, int fa) {
  dp[u][1] = dp[fa][1] + n - sz[u] * 2;
  ans = max(ans, dp[u][1]);
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs2(v, u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), adde(u, v), adde(v, u);
  dfs1(1, 0);
  ans = dp[1][1] = dp[1][0];
  for (int i = head[1]; i; i = e[i].next) dfs2(e[i].to, 1);
  printf("%lld\n", ans);
  return 0;
}
