#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return (!y ? x : gcd(y, x % y)); }
long long to_int(string sconvert) {
  stringstream geek(sconvert);
  long long xconvert = 0;
  geek >> xconvert;
  return xconvert;
}
const long long MAXN = 3e5 + 5, MAX_LOG = 40, MOD = 1e9 + 7, INF = 1e9;
const double PI = acos(-1);
long long mod(long long x) { return (x % MOD + MOD) % MOD; }
long long power(long long x, long long y) {
  if (y == 0) return 1;
  long long c = power(x, y / 2);
  c = (c * c) % MOD;
  if (y % 2) c = (c * x) % MOD;
  return c;
}
long long n, m;
vector<long long> g[MAXN];
long long subtree[MAXN];
long long h[MAXN], ans[MAXN];
void dfs2(long long d, long long p) {
  if (d != 1) ans[d] = ans[p] + (n - subtree[d] - 1) - (subtree[d] + 1);
  for (auto u : g[d])
    if (u != p) dfs2(u, d);
}
void dfs(long long d, long long p) {
  for (long long u : g[d])
    if (u != p) {
      h[u] = h[d] + 1;
      dfs(u, d);
      subtree[d] += subtree[u] + 1;
    }
}
long long MAIN() {
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  h[1] = 1;
  dfs(1, 0);
  for (long long i = 1; i <= n; i++) ans[1] += h[i];
  dfs2(1, 0);
  long long res = 0;
  for (long long i = 1; i <= n; i++) res = max(res, ans[i]);
  cout << res << '\n';
  return 0;
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long t = 1;
  while (t--) MAIN();
  return 0;
}
