#include <bits/stdc++.h>
using namespace std;
const long long int N = 200010;
long long int n, res;
vector<long long int> g[N];
long long int sz[N], dp[N];
void dfs(long long int u, long long int p = -1) {
  sz[u] = 1;
  for (long long int v : g[u]) {
    if (v != p) {
      dfs(v, u);
      sz[u] += sz[v];
      dp[u] += dp[v];
    }
  }
  dp[u] += sz[u];
}
void dfs1(long long int u, long long int p = -1) {
  res = max(res, dp[u]);
  for (long long int v : g[u]) {
    if (v == p) continue;
    dp[u] -= dp[v];
    dp[u] -= sz[v];
    sz[u] -= sz[v];
    sz[v] += sz[u];
    dp[v] += dp[u];
    dp[v] += sz[u];
    dfs1(v, u);
    dp[v] -= sz[u];
    dp[v] -= dp[u];
    sz[v] -= sz[u];
    sz[u] += sz[v];
    dp[u] += sz[v];
    dp[u] += dp[v];
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long int i = 0; i < n - 1; ++i) {
    long long int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1);
  dfs1(1);
  cout << res << '\n';
  return 0;
}
