#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 2e5 + 5;
long long siz[MAX_N];
vector<long long> g[MAX_N];
long long n;
long long sum;
void dfs(long long v, long long last) {
  siz[v] = 1;
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == last) continue;
    dfs(u, v);
    siz[v] += siz[u];
  }
}
long long ans = 0;
void DFS(long long v, long long last, long long cur) {
  ans = max(ans, cur);
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == last) continue;
    DFS(u, v, cur + n - 2 * siz[u]);
  }
}
signed main() {
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  for (long long i = 1; i <= n; i++) sum += siz[i];
  DFS(1, 0, sum);
  cout << ans << endl;
  return 0;
}
