#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const long long mod = 1e9 + 7;
int sz[maxn];
long long f[maxn], ans = 0;
vector<int> g[maxn];
void getsz(int x, int fa) {
  sz[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int v = g[x][i];
    if (v == fa) continue;
    getsz(v, x);
    sz[x] += sz[v];
  }
}
void dfs1(int x, int fa) {
  f[x] = sz[x];
  for (int i = 0; i < g[x].size(); i++) {
    int v = g[x][i];
    if (v == fa) continue;
    dfs1(v, x);
    f[x] += f[v];
  }
}
void dfs2(int x, int fa) {
  ans = max(ans, f[x]);
  for (int i = 0; i < g[x].size(); i++) {
    int v = g[x][i];
    if (v == fa) continue;
    int szx = sz[x], szv = sz[v];
    long long fx = f[x], fv = f[v];
    f[x] -= sz[v] + f[v];
    sz[x] -= sz[v];
    sz[v] += sz[x];
    f[v] += f[x] + sz[x];
    dfs2(v, x);
    f[x] = fx;
    f[v] = fv;
    sz[x] = szx;
    sz[v] = szv;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n - 1); i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  getsz(1, 0);
  dfs1(1, 0);
  dfs2(1, 0);
  cout << ans;
}
