#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long MOD = 998244353;
double eps = 1e-12;
long long n;
long long dp[200200];
long long sz[200200];
vector<long long> g[200200];
void dfs1(long long nn, long long pp) {
  sz[nn] = 1;
  for (auto v : g[nn]) {
    if (v == pp) continue;
    dfs1(v, nn);
    sz[nn] += sz[v];
  }
}
void dfs2(long long nn, long long pp) {
  dp[nn] = sz[nn];
  for (auto v : g[nn]) {
    if (v == pp) continue;
    dfs2(v, nn);
    dp[nn] += dp[v];
  }
}
long long ans = 0;
void dfs3(long long nn, long long pp) {
  ans = max(ans, dp[nn]);
  for (auto v : g[nn]) {
    if (v == pp) continue;
    dp[nn] -= dp[v];
    sz[nn] -= sz[v];
    dp[nn] -= sz[v];
    dp[v] += dp[nn];
    sz[v] += sz[nn];
    dp[v] += sz[nn];
    dfs3(v, nn);
    dp[v] -= dp[nn];
    dp[v] -= sz[nn];
    sz[v] -= sz[nn];
    dp[nn] += dp[v];
    dp[nn] += sz[v];
    sz[nn] += sz[v];
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  dfs3(1, 0);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
