#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M = 1e9 + 7;
long long f[N];
int g[N], ver[N << 1], ne[N << 1], h[N], tot;
long long n, x, ma = 0;
void dfs(int u, int p) {
  g[u] = 1;
  for (int k = h[u]; k; k = ne[k]) {
    int v = ver[k];
    if (v == p) continue;
    dfs(v, u);
    f[u] += f[v];
    g[u] += g[v];
  }
  f[u] += g[u];
}
void dfs2(int u, int p) {
  for (int k = h[u]; k; k = ne[k]) {
    int v = ver[k];
    if (v == p) continue;
    f[v] = f[u] - g[v] - g[v] + n;
    ma = max(ma, f[v]);
    dfs2(v, u);
  }
}
void add(int u, int v) {
  ver[++tot] = v;
  ne[tot] = h[u];
  h[u] = tot;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    add(u, v);
    add(v, u);
  }
  dfs(1, -1);
  ma = f[1];
  dfs2(1, -1);
  cout << ma << endl;
  return 0;
}
