#include <bits/stdc++.h>
using namespace std;
template <typename A1>
void prn(A1&& arg) {
  cout << arg << '\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args) {
  cout << arg << ' ';
  prn(args...);
}
vector<long long> v[200005];
long long dp[200005], tmp, ans, orig;
void dfs(long long x, long long p = 0) {
  for (long long y : v[x])
    if (y != p) {
      dfs(y, x);
      dp[x] += dp[y];
    }
  dp[x]++;
}
void rrt(long long x, long long p = 0) {
  if (p != 0) {
    dp[p] -= dp[x];
    tmp -= dp[x];
    dp[x] += dp[p];
    tmp += dp[p];
    ans = max(ans, tmp);
  }
  for (long long y : v[x])
    if (y != p) rrt(y, x);
  if (p != 0) {
    dp[x] -= dp[p];
    tmp -= dp[p];
    dp[p] += dp[x];
    tmp += dp[x];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long x, y, m = n - 1;
  while (m--) {
    cin >> x >> y;
    v[x].emplace_back(y);
    v[y].emplace_back(x);
  }
  dfs(1);
  for (long long i = 1; i <= n; i++) orig += dp[i];
  tmp = orig;
  rrt(1);
  prn(ans);
}
