#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
template <class nmsl>
inline void read(nmsl &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
}
long long n, f[N], size[N], root[N], hd[N], bianshu, ans;
struct abc {
  int nxt, to;
} qwq[N * 2];
inline void addedg(int lai, int qu) {
  qwq[++bianshu].nxt = hd[lai];
  qwq[bianshu].to = qu;
  hd[lai] = bianshu;
}
inline void first_dp(int u, int father) {
  size[u] = 1;
  for (register int i = hd[u]; i; i = qwq[i].nxt) {
    int v = qwq[i].to;
    if (v == father) continue;
    first_dp(v, u);
    size[u] += size[v];
    f[u] += f[v];
  }
  f[u] += size[u];
  return;
}
inline void dp(int u, int father) {
  f[u] = 0;
  for (register int i = hd[u]; i; i = qwq[i].nxt) {
    int v = qwq[i].to;
    f[u] += f[v];
  }
  long long tot = f[u] + n;
  ans = max(ans, tot);
  for (register int i = hd[u]; i; i = qwq[i].nxt) {
    int v = qwq[i].to;
    if (v == father) continue;
    size[u] = n - size[v];
    f[u] = tot - f[v] - size[v];
    dp(v, u);
  }
}
int main() {
  read(n);
  for (register int i = 1, qa, qb; i < n; i++)
    read(qa), read(qb), addedg(qa, qb), addedg(qb, qa);
  first_dp(1, 0);
  ans = f[1];
  dp(1, 0);
  cout << ans;
  return 0;
}
