#include <bits/stdc++.h>
using namespace std;
const int nsz = 2e5;
int n, rt = 1;
long long siz[nsz + 5], dp[nsz + 5], ans;
vector<int> g[nsz + 5];
int inline read() {
  int res = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar())
    ;
  return res;
}
void dfs(int u = rt, int p = rt) {
  siz[u] = 1;
  for (int v : g[u]) {
    if (v == p) continue;
    dfs(v, u);
    siz[u] += siz[v];
  }
}
long long calc(int u = rt, int p = rt) {
  long long res = siz[u];
  for (int v : g[u]) {
    if (v == p) continue;
    res += calc(v, u);
  }
  return res;
}
void solve(int u = rt, int p = rt) {
  for (int v : g[u]) {
    if (v == p) continue;
    dp[v] = dp[u] - siz[v] + siz[rt] - siz[v];
    solve(v, u);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  n = read();
  for (int i = 1; i <= n - 1; ++i) {
    int u = read(), v = read();
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs();
  dp[rt] = calc();
  solve();
  for (int u = 1; u <= n; ++u) {
    ans = max(ans, dp[u]);
  }
  cout << ans << '\n';
}
