#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 2e5 + 5;
vector<int> G[maxn];
int siz[maxn];
long long sum, ans;
void dfs(int rt, int fa) {
  siz[rt] = 1;
  for (auto i : G[rt]) {
    if (i == fa) continue;
    dfs(i, rt);
    siz[rt] += siz[i];
  }
}
void move(int now, int nxt) {
  sum -= siz[now] + siz[nxt];
  siz[now] -= siz[nxt];
  siz[nxt] += siz[now];
  sum += siz[now] + siz[nxt];
  ans = max(ans, sum);
}
void dfs1(int rt, int fa) {
  for (auto i : G[rt]) {
    if (i == fa) continue;
    move(rt, i);
    dfs1(i, rt);
    move(i, rt);
  }
}
int u, v;
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) sum += siz[i];
  ans = sum;
  dfs1(1, 0);
  cout << ans;
}
