#include <bits/stdc++.h>
using namespace std;
long long n, i, a, b, child[200001], sub[200001], sum_sub_child[200001],
    ans[200001];
vector<long long> g[200001];
void dfs(long long x, long long p) {
  for (auto it : g[x]) {
    if (it != p) {
      dfs(it, x);
      child[x] += child[it];
      sum_sub_child[x] += sub[it];
    }
  }
  sub[x] = child[x] + sum_sub_child[x];
}
void dfs2(long long x, long long p) {
  if (p == 0)
    ans[x] = sub[x];
  else
    ans[x] = ans[p] - child[x] - child[x] + n;
  for (auto it : g[x]) {
    if (it != p) dfs2(it, x);
  }
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    child[i] = 1;
  }
  child[n] = 1;
  dfs(1, 0);
  dfs2(1, 0);
  a = 0;
  for (i = 1; i <= n; i++) a = max(a, ans[i]);
  cout << a << endl;
}
