#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
vector<int> g[N];
long long sz[N], sc[N];
void dfs(int x, int y = -1) {
  for (auto v : g[x])
    if (v != y) {
      dfs(v, x);
      sz[x] += sz[v];
      sc[x] += sc[v];
    }
  sz[x] += 1;
  sc[x] += sz[x];
}
int n;
long long rsc[N];
void solve(int x, int y = -1, long long a = 0) {
  long long sum = 0;
  for (auto v : g[x])
    if (v != y) {
      sum += sc[v];
    }
  rsc[x] = max(sc[x], n - sz[x] + sc[x] + a);
  for (auto v : g[x])
    if (v != y) {
      solve(v, x, a + sum - sc[v] + n - sz[v]);
    }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0);
  solve(0);
  long long r = 0;
  for (int i = 0; i < n; i++) r = max(r, rsc[i]);
  cout << r << '\n';
  return 0;
}
