#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 3;
long long n, ans, sz[N], up[N], down[N];
vector<long long> q[N];
void dfs1(long long v, long long p) {
  sz[v] = 1;
  for (auto i : q[v]) {
    if (i != p) {
      dfs1(i, v);
      sz[v] += sz[i];
      down[v] += down[i] + sz[i];
    }
  }
}
void dfs2(long long v, long long p) {
  if (p != -1) {
    up[v] = down[p] + up[p] - (down[v] + sz[v]) + (sz[1] - sz[v]);
  }
  ans = max(ans, down[v] + up[v] + n);
  for (auto i : q[v]) {
    if (i != p) {
      dfs2(i, v);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    q[x].push_back(y);
    q[y].push_back(x);
  }
  dfs1(1, -1);
  dfs2(1, -1);
  cout << ans;
}
