#include <bits/stdc++.h>
using namespace std;
long long initDp(long long v, long long par, long long *dp, long long n,
                 vector<long long> *adj, long long *sz) {
  if (dp[v] != -1) return dp[v];
  long long sum = 0;
  for (long long i = 0; i < adj[v].size(); i++) {
    long long u = adj[v][i];
    if (u == par) continue;
    sum += initDp(u, v, dp, n, adj, sz);
    sz[v] += sz[u];
  }
  dp[v] = sum + sz[v];
  return dp[v];
}
void dfs(long long v, long long par, long long *dp, long long n,
         vector<long long> *adj, long long *sz, long long &res) {
  for (long long i = 0; i < adj[v].size(); i++) {
    long long u = adj[v][i];
    if (u == par) continue;
    dp[v] -= (sz[u] + dp[u]);
    sz[v] -= sz[u];
    dp[u] += (sz[v] + dp[v]);
    sz[u] += sz[v];
    if (res < dp[u]) {
      res = dp[u];
    }
    dfs(u, v, dp, n, adj, sz, res);
    dp[u] -= (sz[v] + dp[v]);
    sz[u] -= sz[v];
    dp[v] += sz[u] + dp[u];
    sz[v] += sz[u];
  }
  return;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> adj[n + 1];
  for (long long i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  long long dp[n + 1], sz[n + 1];
  for (long long i = 0; i <= n; i++) {
    dp[i] = -1;
    sz[i] = 1;
  }
  initDp(1, -1, dp, n, adj, sz);
  long long root = 1;
  long long res = dp[root];
  dfs(1, -1, dp, n, adj, sz, res);
  cout << res << "\n";
  return 0;
}
