#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void err(istream_iterator<string> it) { cout << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << " ";
  err(++it, args...);
}
long long pow(long long x, long long y) {
  if (y == 0) return 1;
  long long temp = pow(x, y / 2);
  temp = (temp * temp);
  if (y % 2 == 1) temp *= x;
  return temp;
}
const long long MAXN = 2E5 + 100;
vector<vector<long long> > adj(MAXN);
long long n, dp[MAXN], dp2[MAXN], dp3[MAXN], a[MAXN];
void DFS(long long u = 0, long long p = -1) {
  dp[u] = 1;
  for (long long v : adj[u]) {
    if (v == p) continue;
    DFS(v, u);
    dp[u] += dp[v];
    dp2[u] += dp2[v];
  }
  dp2[u] += dp[u];
}
void reroot(long long u = 0, long long p = -1) {
  for (long long v : adj[u]) {
    if (v == p) continue;
    dp3[v] = dp3[u] + dp[0] - 2 * dp[v];
    reroot(v, u);
  }
}
int32_t main() {
  cin >> n;
  for (long long i = 0, u, v; i < n - 1; i++) {
    cin >> u >> v, --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  DFS(0);
  dp3[0] = dp2[0];
  reroot(0);
  long long res = 0;
  for (long long i = 0; i < n; i++) res = max(res, dp3[i]);
  cout << res;
}
