#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
struct N {
  int v, nxt;
} edge[maxn * 4];
int head[maxn * 4], cnt, n;
long long t[maxn], ans;
void add(int u, int v) {
  ++cnt;
  edge[cnt].v = v;
  edge[cnt].nxt = head[u];
  head[u] = cnt;
}
void dfs(int u, int f) {
  t[u] = 1;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].v;
    if (v == f) continue;
    dfs(v, u);
    t[u] += t[v];
  }
  ans += t[u];
}
void dfs1(int u, int f, long long val) {
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].v;
    if (v == f) continue;
    long long temp = val - t[v] + n - t[v];
    ans = max(ans, temp);
    dfs1(v, u, temp);
  }
}
int main() {
  int u, v;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &u, &v);
    add(u, v);
    add(v, u);
  }
  dfs(1, 0);
  dfs1(1, 0, ans);
  cout << ans << endl;
  return 0;
}
