#include <bits/stdc++.h>
const long long p = 400000;
long long n, hason[p], f[p], yy = 1;
long long u, v;
long long tot, la[p * 2], to[p * 2], h[p];
void hsb(long long x, long long y) {
  to[++tot] = y, la[tot] = h[x], h[x] = tot;
}
long long hsc(long long x, long long y) {
  for (long long i = h[x]; i; i = la[i])
    if (to[i] != y) hason[x] += 1 + hsc(to[i], x);
  return hason[x];
}
void hsa(long long x, long long y) {
  f[x] = f[y] - (hason[x] + 1) + (n - hason[x] - 1);
  for (long long i = h[x]; i; i = la[i])
    if (to[i] != y) hsa(to[i], x);
}
void hsd(long long x, long long y, long long z) {
  f[1] += z;
  for (long long i = h[x]; i; i = la[i])
    if (to[i] != y) hsd(to[i], x, z + 1);
}
signed main() {
  std::cin >> n;
  for (long long i = 1; i < n; i++) {
    std::cin >> u >> v;
    hsb(u, v), hsb(v, u);
  }
  hsc(1, 0);
  for (long long i = h[1]; i; i = la[i]) hsd(to[i], 1, 1);
  for (long long i = h[1]; i; i = la[i]) hsa(to[i], 1);
  for (long long i = 2; i <= n; i++)
    if (f[i] > f[yy]) yy = i;
  std::cout << f[yy] + n << std::endl;
  return 0;
}
