#include <bits/stdc++.h>
using namespace std;
int n, tmf, tms;
vector<int> d[200010];
long long sz[200010], dp[200010], anw, temp;
long long dfs0(int now, int par) {
  sz[now] = 1;
  for (int i = int(0); i <= int(d[now].size() - 1); i++)
    if (d[now][i] != par) sz[now] += dfs0(d[now][i], now);
  return sz[now];
}
long long dfs1(int now, int par) {
  dp[now] = sz[now];
  for (int i = int(0); i <= int(d[now].size() - 1); i++)
    if (d[now][i] != par) dp[now] += dfs1(d[now][i], now);
  return dp[now];
}
void mdfs(int now, int par) {
  anw = max(anw, temp);
  for (int i = int(0); i <= int(d[now].size() - 1); i++)
    if (d[now][i] != par) {
      long long tmp = temp;
      temp = temp + sz[1] - sz[d[now][i]] - sz[d[now][i]];
      mdfs(d[now][i], now);
      temp = tmp;
    }
}
int main() {
  cin >> n;
  for (int i = int(2); i <= int(n); i++) {
    scanf("%d %d", &tmf, &tms);
    d[tmf].push_back(tms);
    d[tms].push_back(tmf);
  }
  dfs0(1, 0);
  dfs1(1, 0);
  temp = dp[1];
  mdfs(1, 0);
  cout << anw;
}
