#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<vector<ll>> adj{};
ll subtree_size[(int)2e5];
ll dp1[(int)2e5];
ll dp2[(int)2e5];
void dfs(int u, int v = -1) {
  subtree_size[u] = 1;
  for (auto el : adj[u]) {
    if (el == v) continue;
    dfs(el, u);
    subtree_size[u] += subtree_size[el];
  }
  if (adj[u].size() == 1 && adj[u].front() == v)
    dp1[u] = n, dp2[u] = 1;
  else {
    ll sm_dp1{};
    ll sm_dp2{};
    for (auto el : adj[u]) {
      if (el == v) continue;
      sm_dp1 += dp1[el];
      sm_dp2 += dp2[el];
    }
    for (auto el : adj[u]) {
      if (el == v) continue;
      dp1[u] = max(dp1[u], dp1[el] + sm_dp2 + n - subtree_size[el] - dp2[el]);
      dp2[u] += dp2[el];
    }
    dp2[u] += subtree_size[u];
  }
}
int main() {
  cin >> n;
  adj.resize(n);
  for (auto i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0);
  cout << dp1[0] << endl;
}
