#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
vector<int> g[200005];
map<int, long long> dp[200005], D[200005];
int N, a, b, P[200005], S[200005];
int sum(int u, int p) {
  S[u] = 1, P[u] = p;
  for (auto &h : g[u])
    if (h ^ p) S[u] += sum(h, u);
  return S[u];
}
long long X, V[200005];
long long dfs(int u, int p) {
  if (dp[u].count(p)) return dp[u][p];
  if (dp[u].empty()) {
    long long &v = V[u];
    v = (p ^ P[u] ? N - S[p] : S[u]);
    for (auto &h : g[u])
      if (h ^ p) v += D[u][h] = dfs(h, u);
    return dp[u][p] = v;
  }
  long long v = V[u] - D[u][p] + (~P[u] ? dfs(P[u], u) : 0) -
                (P[u] ^ P[u] ? N - S[P[u]] : S[u]) +
                (p ^ P[u] ? N - S[p] : S[u]);
  return dp[u][p] = v;
}
int main(void) {
  scanf("%d", &N);
  for (int i(0); i < N - 1; i++)
    scanf("%d%d", &a, &b), g[--a].push_back(--b), g[b].push_back(a);
  sum(0, -1);
  for (int i(0); i < N; i++) X = max(X, dfs(i, -1));
  printf("%lld\n", X);
  return 0;
}
