#include <bits/stdc++.h>
using namespace std;
vector<int> vi[200200];
int dp[200200];
int dfs(int now, int prev) {
  dp[now] = 1;
  for (auto x : vi[now]) {
    if (x == prev) continue;
    dp[now] += dfs(x, now);
  }
  return dp[now];
}
long long int rose = 0;
int n;
void rec(int now, int prev, long long int sum) {
  rose = max(rose, sum);
  for (auto x : vi[now]) {
    if (x == prev) continue;
    rec(x, now, sum - dp[x] + (n - dp[x]));
  }
}
int main() {
  int i, j, k, x, y, ans, curr, temp, m;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    vi[x].push_back(y);
    vi[y].push_back(x);
  }
  dfs(1, 0);
  for (i = 1; i <= n; i++) rose += dp[i];
  rec(1, 0, rose);
  printf("%lld\n", rose);
  return 0;
}
