#include <bits/stdc++.h>
using namespace std;
template <class FR>
inline FR max(FR &a, const FR &b) {
  return (a > b) ? a : b;
}
template <class FR>
inline FR min(FR &a, const FR &b) {
  return (a > b) ? b : a;
}
template <class FR>
inline FR eqMax(FR &a, FR b) {
  return (a > b) ? a : a = b;
}
template <class FR>
inline FR eqMin(FR a, FR b) {
  return (a > b) ? a = b : a;
}
vector<long long> adj[200100];
long long a[200100];
long long dp[200100];
long long n;
void dfs(long long v, long long p = -1) {
  a[v] = 1;
  for (long long x : adj[v]) {
    if (x == p) {
      continue;
    }
    dfs(x, v);
    a[v] += a[x];
  }
  dp[0] += a[v];
}
void redfs(long long v, long long p = -1) {
  for (long long x : adj[v]) {
    if (x == p) {
      continue;
    }
    dp[x] = dp[v] + n - 2 * a[x];
    redfs(x, v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(0);
  redfs(0);
  cout << *max_element(begin(dp), end(dp));
  return 0;
}
