#include <bits/stdc++.h>
using namespace std;
long long n, ans[200005], sz[200005], szs[200005], out;
vector<long long> v[200005];
long long dfs1(int ver, int par) {
  sz[ver] = 1;
  for (int i = 0; i < v[ver].size(); i++) {
    if (v[ver][i] == par) continue;
    sz[ver] += dfs1(v[ver][i], ver);
  }
  return sz[ver];
}
long long dfs2(int ver, int par) {
  long long sum = 0;
  for (int i = 0; i < v[ver].size(); i++) {
    if (v[ver][i] == par) continue;
    sum += dfs2(v[ver][i], ver);
  }
  return szs[ver] = sum + sz[ver];
}
void dfs3(int ver, int par, long long sum) {
  ans[ver] = sum + szs[ver] - sz[ver] + n;
  out = max(out, ans[ver]);
  long long x, y;
  for (int i = 0; i < v[ver].size(); i++) {
    if (v[ver][i] == par) continue;
    x = n - sz[v[ver][i]] + szs[ver] - szs[v[ver][i]] - sz[ver];
    dfs3(v[ver][i], ver, sum + x);
  }
  return;
}
int main() {
  cin >> n;
  int x, y;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs1(1, -1);
  dfs2(1, -1);
  dfs3(1, -1, 0);
  cout << out << endl;
}
