#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200200];
long long dp[200200], ans;
int n, sz[200200];
void dfs(int u, int f = 0) {
  sz[u] = 1;
  for (int v : adj[u]) {
    if (v == f) continue;
    dfs(v, u);
    dp[u] += dp[v];
    sz[u] += sz[v];
  }
  dp[u] += sz[u];
}
void redfs(int u, int f = 0) {
  ans = max(ans, dp[u]);
  long long sum = dp[u] - n;
  for (int v : adj[u]) {
    if (v == f) continue;
    dp[v] = sum - dp[v] + n - sz[v] + dp[v] - sz[v] + n;
    redfs(v, u);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1);
  redfs(1);
  cout << ans << endl;
  return 0;
}
