#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int head[N], nxt[N * 2], v[N * 2], ptr, sz[N], n;
long long dp[N], g[N];
void add_edge(int uu, int vv) {
  v[ptr] = vv;
  nxt[ptr] = head[uu];
  head[uu] = ptr++;
}
void dfs1(int pos, int fa) {
  sz[pos] = 1;
  for (int i = head[pos]; i != -1; i = nxt[i]) {
    if (v[i] == fa) continue;
    dfs1(v[i], pos);
    sz[pos] += sz[v[i]];
    dp[pos] += dp[v[i]];
  }
  dp[pos] += sz[pos];
}
void dfs2(int pos, int fa) {
  for (int i = head[pos]; i != -1; i = nxt[i]) {
    if (v[i] == fa) continue;
    g[v[i]] = n - sz[v[i]] + g[pos] + dp[pos] - sz[pos] - dp[v[i]];
    dfs2(v[i], pos);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  memset(head, -1, sizeof(head));
  memset(nxt, -1, sizeof(nxt));
  int t1, t2;
  for (int i = 1; i < n; i++) {
    cin >> t1 >> t2;
    add_edge(t1, t2);
    add_edge(t2, t1);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, dp[i] + g[i] + n - sz[i]);
  cout << ans << endl;
  return 0;
}
