#include <bits/stdc++.h>
using namespace std;
void fopen() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
long long dp[200000], ans[200000], dp1[200000];
vector<int> a[200000];
int f = 1, n;
void dfs(int i, int p) {
  for (auto x : a[i]) {
    if (x != p) {
      dfs(x, i);
      dp[i] += dp[x];
    }
  }
  dp[i] += (f ? 1 : 0);
}
void dfs1(int i, int p) {
  ans[i] = ans[p] + (i ? -dp1[i] + (n - dp1[i]) : 0);
  for (auto x : a[i]) {
    if (x != p) {
      dfs1(x, i);
    }
  }
}
void htatfrukin() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int p, q;
    cin >> p >> q;
    a[p - 1].push_back(q - 1);
    a[q - 1].push_back(p - 1);
  }
  dfs(0, -1);
  f = 0;
  for (int i = 0; i < n; i++) {
    dp1[i] = dp[i];
  }
  dfs(0, -1);
  ans[0] = dp[0];
  dfs1(0, 0);
  long long m = 0;
  for (int i = 0; i < n; i++) {
    m = max(m, ans[i]);
  }
  cout << m;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  for (int i = 0; i < 1; i++) {
    htatfrukin();
    cout << endl;
  }
}
