#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, MOD1 = (119 << 23) | 1;
const int INF = 1e9 + 5, MAX = 2e5 + 5;
int siz[MAX];
long long dp[MAX];
long long ans = 0;
vector<int> d[MAX];
void calc(int u = 1, int v = 0) {
  siz[u] = 1;
  for (int it : d[u]) {
    if (it == v) continue;
    calc(it, u);
    siz[u] += siz[it];
    dp[u] += dp[it];
  }
  dp[u] += siz[u];
}
void dfs(int u = 1, int v = 0) {
  ans = max(ans, dp[u]);
  for (int it : d[u]) {
    if (it == v) continue;
    dp[u] -= dp[it];
    dp[u] -= siz[it];
    siz[u] -= siz[it];
    siz[it] += siz[u];
    dp[it] += siz[u];
    dp[it] += dp[u];
    dfs(it, u);
    dp[it] -= dp[u];
    dp[it] -= siz[u];
    siz[it] -= siz[u];
    siz[u] += siz[it];
    dp[u] += siz[it];
    dp[u] += dp[it];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    d[x].push_back(y);
    d[y].push_back(x);
  }
  calc();
  dfs();
  cout << ans << "\n";
  return 0;
}
