#include <bits/stdc++.h>
using namespace std;
vector<long long int> arr[200001];
long long int w[200001] = {0};
long long int dp[200001][2];
long long int n;
void dfs(long long int s, long long int pra) {
  w[s] = 1;
  long long int sum = 0;
  long long int ma = 0;
  for (long long int it : arr[s]) {
    if (it != pra) {
      dfs(it, s);
      w[s] += w[it];
      sum += dp[it][0];
    }
  }
  dp[s][0] = w[s] + sum;
  if (w[s] == 1)
    dp[s][1] = n;
  else {
    for (long long int ind : arr[s])
      if (ind != pra)
        dp[s][1] = max(dp[s][1], n - w[ind] + sum - dp[ind][0] + dp[ind][1]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(dp, 0, sizeof(dp));
  cin >> n;
  long long int a, b;
  for (int x = 0; x < n - 1; x++) {
    cin >> a >> b;
    arr[a].push_back(b);
    arr[b].push_back(a);
  }
  dfs(1, -1);
  cout << max(dp[1][0], dp[1][1]) << endl;
}
