#include <bits/stdc++.h>
using namespace std;
vector<int> vertexs[300000];
long long neko[300000];
vector<pair<long long, long long>> nexting[300000];
long long move(long long now, long long back) {
  long long cnt = 1;
  for (long long i = 0; i < vertexs[now].size(); ++i) {
    if (vertexs[now][i] != back) {
      long long geko = move(vertexs[now][i], now);
      cnt += geko;
      nexting[now].push_back(make_pair(vertexs[now][i], geko));
    }
  }
  return neko[now] = cnt;
}
long long n;
long long tree_dp(long long now, long long back, long long now_ans) {
  long long final_ans = now_ans;
  for (int q = 0; q < nexting[now].size(); ++q) {
    if (nexting[now][q].first != back) {
      long long pre_ans = now_ans - neko[nexting[now][q].first];
      pre_ans += n - nexting[now][q].second;
      final_ans = max(final_ans, tree_dp(nexting[now][q].first, now, pre_ans));
    }
  }
  return final_ans;
}
int main() {
  iostream::sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < n - 1; ++i) {
    long long a, b;
    cin >> a >> b;
    vertexs[a].push_back(b);
    vertexs[b].push_back(a);
  }
  move(1, -1);
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    ans += neko[i + 1];
  }
  ans -= n;
  cout << tree_dp(1, -1, ans) + n << endl;
}
