#include <bits/stdc++.h>
using namespace std;
char char_read_before = 1;
inline int read() {
  int f = 1, x = 0;
  char s = char_read_before;
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 - '0' + s;
    s = getchar();
  }
  char_read_before = s;
  return x * f;
}
int zxy = 998244353;
int n, m, i, j, s, o, k;
vector<int> g[200005];
long long dp1[200005], dp2[200005];
long long son[200005];
inline void dfs1(int x, int fa) {
  son[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] != fa) {
      dfs1(g[x][i], x);
      dp1[x] += dp1[g[x][i]];
      son[x] += son[g[x][i]];
    }
  }
  dp1[x] += son[x];
  return;
}
inline void dfs2(int x, int fa) {
  if (fa) {
    dp2[x] = n - son[x] + 0ll + (dp2[fa] + dp1[fa] - son[x] - dp1[x]);
  }
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] != fa) {
      dfs2(g[x][i], x);
    }
  }
  return;
}
signed main() {
  n = read();
  for (int i = 1; i < n; i++) {
    s = read();
    o = read();
    g[s].push_back(o);
    g[o].push_back(s);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp1[i] + dp2[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
