#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v;
} e[400005];
int head[200005], nxt[400005], cnt;
void addnode(int u, int v) {
  e[++cnt] = (edge){u, v};
  nxt[cnt] = head[u];
  head[u] = cnt;
}
int siz[200005], fa[200005], n;
long long dp[200005], ans;
void dfs(int u) {
  siz[u] = 1;
  for (int i = head[u]; i; i = nxt[i])
    if (!siz[e[i].v]) {
      dfs(e[i].v);
      fa[e[i].v] = u;
      siz[u] += siz[e[i].v];
    }
  dp[1] += siz[u];
}
void DFS(int u) {
  if (u != 1) ans = max(ans, dp[u] = dp[fa[u]] + n - 2 * siz[u]);
  for (int i = head[u]; i; i = nxt[i])
    if (e[i].v != fa[u]) DFS(e[i].v);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addnode(u, v), addnode(v, u);
  }
  dfs(1);
  DFS(1);
  cout << ans;
  return 0;
}
