#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[200002];
long long sz[200002];
long long sc[200002];
bool vis[200002];
long long diff[200002];
long long ans[200002];
long long mx = -1000000;
void dfs(long long u) {
  sz[u] = 1, sc[u] = 0;
  vis[u] = 1;
  for (auto v : adj[u])
    if (!vis[v]) {
      dfs(v);
      sz[u] += sz[v];
      sc[u] += sc[v];
    }
  sc[u] += sz[u];
}
void dfs2(long long u) {
  vis[u] = 1;
  for (auto v : adj[u])
    if (!vis[v]) {
      ans[v] = ans[u] - sz[v] + sz[u] - sz[v];
      swap(sz[u], sz[v]), sz[u] = sz[v] - sz[u];
      mx = max(mx, ans[v]), dfs2(v);
      sz[u] = sz[v] - sz[u], swap(sz[u], sz[v]);
    }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i < n; ++i) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1);
  for (long long i = 1; i <= n; ++i) vis[i] = 0;
  ans[1] = sc[1];
  dfs2(1);
  cout << mx;
}
