#include <bits/stdc++.h>
using namespace std;
const long long size = 2e5 + 5;
vector<long long> Edge[size];
long long sz[size];
long long val[size];
long long n;
void down(long long u, long long p) {
  sz[u] = 1;
  for (auto v : Edge[u]) {
    if (v == p) continue;
    down(v, u);
    val[u] += val[v];
    sz[u] += sz[v];
  }
  val[u] += sz[u];
}
void up(long long u, long long p) {
  if (p != 0) {
    val[u] = val[u] + val[p] - sz[u] - val[u] + (n - sz[u]);
  }
  for (auto v : Edge[u])
    if (v != p) up(v, u);
}
int32_t main() {
  scanf("%lld", &n);
  long long u, v;
  for (long long i = 1; i < n; i++) {
    scanf("%lld%lld", &u, &v);
    Edge[u].push_back(v);
    Edge[v].push_back(u);
  }
  down(1, 0);
  up(1, 0);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) ans = max(ans, val[i]);
  printf("%lld\n", ans);
}
