#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
const int N = 2e5 + 5;
vector<int> g[N];
int n, u, v;
long long sz[N], sum[N], dp[N];
void dfs(int u, int o) {
  sz[u] = 1;
  for (int v : g[u]) {
    if (v != o) {
      dfs(v, u);
      sz[u] += sz[v];
    }
  }
  sum[u] = sz[u];
  for (int v : g[u]) {
    if (v != o) {
      sum[u] += sum[v];
    }
  }
}
void DFS(int u, int o) {
  if (u == 1) dp[u] = sum[u];
  for (int v : g[u]) {
    if (v != o) {
      dp[v] = dp[u] + (n - sz[v]) - sz[v];
      DFS(v, u);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i)
    scanf("%d %d", &u, &v), g[u].emplace_back(v), g[v].emplace_back(u);
  dfs(1, 0);
  DFS(1, 0);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans = max(ans, dp[i]);
  printf("%lld\n", ans);
  return 0;
}
