#include <bits/stdc++.h>
using namespace std;
const int N = 210000;
int n, siz[N];
long long dp[N], Dp[N];
vector<int> adj[N];
void dfs(int v, int par) {
  siz[v] = 1;
  dp[v] = 0;
  for (__typeof((adj[v]).begin()) i = (adj[v]).begin(); i != (adj[v]).end();
       ++i)
    if (*i != par) {
      dfs(*i, v);
      siz[v] += siz[*i];
      dp[v] += dp[*i];
    }
  dp[v] += siz[v];
}
void dfs2(int v, int par) {
  for (__typeof((adj[v]).begin()) i = (adj[v]).begin(); i != (adj[v]).end();
       ++i)
    if (*i != par) {
      Dp[*i] = Dp[v] + n - 2 * siz[*i];
      dfs2(*i, v);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(0, -1);
  Dp[0] = dp[0];
  dfs2(0, -1);
  long long ans = *max_element(Dp, Dp + n);
  printf("%lld\n", ans);
}
