#include <bits/stdc++.h>
using namespace std;
const int sqr = 500;
const long long P = (1000 * 1000 * 1000) + 7;
const int arrn = 2e5 + 3;
const int arrn2 = 1e3 + 1;
long long n;
vector<long long> tree[arrn];
long long par[arrn] = {};
long long ccnt[arrn] = {};
long long ans = 0;
long long maxinc = 0;
void dfs(long long i, long long p, long long dep) {
  par[i] = p;
  ans += dep;
  ccnt[i] = 1;
  for (int j = 0; j < (int)tree[i].size(); j++) {
    if (tree[i][j] != p) {
      dfs(tree[i][j], i, dep + 1);
      ccnt[i] += ccnt[tree[i][j]];
    }
  }
}
void dfs1(long long i, long long p, long long pass) {
  pass += n - 2 * ccnt[i];
  maxinc = max(maxinc, pass);
  for (int j = 0; j < (int)tree[i].size(); j++) {
    if (tree[i][j] != p) {
      dfs1(tree[i][j], i, pass);
    }
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    tree[v].push_back(u);
    tree[u].push_back(v);
  }
  dfs(1, 0, 1);
  dfs1(1, 0, n);
  cout << ans + maxinc;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
