#include <bits/stdc++.h>
using namespace std;
long long n, i, u, v, visited[200003], dp[200003], sub[200003], ans;
vector<long long> g[200003];
void dfs(long long x) {
  visited[x] = 1;
  sub[x] = 1;
  dp[x] = 0;
  for (auto it : g[x]) {
    if (!visited[it]) {
      dfs(it);
      sub[x] += sub[it];
      dp[x] += dp[it];
    }
  }
  dp[x] += sub[x];
}
void dfs1(long long x) {
  visited[x] = 1;
  for (auto it : g[x]) {
    if (visited[it]) {
      dp[x] += (dp[it] - dp[x] - sub[x]) + (sub[it] - sub[x]);
      sub[x] += (sub[it] - sub[x]);
    }
  }
  ans = max(ans, dp[x]);
  for (auto it : g[x]) {
    if (!visited[it]) {
      dfs1(it);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  memset(visited, 0, sizeof visited);
  ans = dp[0];
  dfs1(0);
  cout << ans;
  return 0;
}
