#include <bits/stdc++.h>
#pragma GCC optimize("-O3", "unroll-loops")
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
  if (a < b) a = b;
}
const long long MOD = 1e9 + 7;
const long long MAX = 200010;
const double pi = acos(-1);
vector<long long> G[200010];
long long dp[200020];
long long dp_init(long long n, long long pre) {
  if (dp[n] != 0) return dp[n];
  long long res = 1;
  for (auto nex : G[n]) {
    if (nex == pre) continue;
    res += dp_init(nex, n);
  }
  dp[n] = res;
  return res;
}
long long ans = 0;
long long N;
bool used[200020];
void calc(long long n, long long res) {
  used[n] = true;
  for (auto nex : G[n]) {
    if (used[nex]) continue;
    long long tmp = res + N - 2 * dp[nex];
    chmax(ans, tmp);
    used[nex] = true;
    calc(nex, tmp);
  }
}
void solve() {
  cin >> N;
  for (long long i = 0; i < N - 1; i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  long long root = 0;
  dp_init(0, 0);
  long long tmp = 0;
  for (long long i = 0; i < N; i++) tmp += dp[i];
  ans = tmp;
  calc(0, tmp);
  cout << ans << '\n';
  ;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
