#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long sz[200010], n;
vector<long long> g[200010];
long long in[200010], out[200010], ans = 0;
void dfs1(long long u, long long p = -1) {
  sz[u] = 1;
  for (auto x : g[u]) {
    if (x == p) continue;
    dfs1(x, u);
    sz[u] += sz[x];
    in[u] += in[x];
  }
  in[u] += sz[u];
}
void dfs2(long long u, long long p = -1) {
  ans = max(ans, out[u] + in[u] + n - sz[u]);
  for (auto x : g[u]) {
    if (x == p) continue;
    out[x] = out[u] + in[u] - in[x] - sz[x] + (n - sz[u]);
    dfs2(x, u);
  }
}
void solve() {
  cin >> n;
  for (long long i = 0, a, b; i < n - 1; ++i) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs1(1);
  dfs2(1);
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t = 1;
  while (t--) solve();
  return 0;
}
