#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200010];
int visited[200010], ct[200010];
long long ans = 0, cur = 0, res = 0, n;
void dfs(int s) {
  visited[s] = 1;
  ct[s] = 1;
  for (auto i : graph[s]) {
    if (!visited[i]) {
      dfs(i);
      ct[s] += ct[i];
    }
  }
  ans += ct[s];
}
void changeroot(int s) {
  visited[s] = 1;
  for (auto i : graph[s]) {
    if (!visited[i]) {
      int t = ct[i];
      ct[s] = n - ct[i];
      ct[i] = n;
      long long temp = ans;
      res = max(res, ans + n - 2 * t);
      ans = ans + n - 2 * t;
      changeroot(i);
      ct[i] = t;
      ct[s] = n;
      ans = temp;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    graph[a - 1].push_back(b - 1);
    graph[b - 1].push_back(a - 1);
  }
  dfs(0);
  res = ans;
  memset(visited, 0, sizeof(visited));
  changeroot(0);
  cout << res << '\n';
}
