#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long linf = 123456789012345678;
const long long mod = 1000000007;
#pragma GCC optimize("Ofast")
long long n;
vector<vector<int> > adj;
vector<int> size;
long long dfs(long long node, long long par) {
  long long d = 1;
  long long s = 0;
  for (long long x : adj[node]) {
    if (x == par) continue;
    d += dfs(x, node);
    s += size[x];
  }
  size[node] = s + 1;
  return d + s;
}
long long dfs2(long long node, long long par, long long dist) {
  long long ans = dist;
  for (auto x : adj[node]) {
    if (x == par) continue;
    long long ndist = dist - size[x] + (n - size[x]);
    ans = max(ans, dfs2(x, node, ndist));
  }
  return ans;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  adj = vector<vector<int> >(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  size = vector<int>(n);
  long long dist = dfs(0, -1);
  cout << dfs2(0, -1, dist) << endl;
}
