#include <bits/stdc++.h>
using namespace std;
long long n, ans;
vector<long long> gr[200005];
long long sub[200005], dp[200005];
void dfs(long long ch, long long par) {
  sub[ch] = 1;
  for (auto i : gr[ch]) {
    if (i != par) {
      dfs(i, ch);
      sub[ch] += sub[i];
      dp[ch] += dp[i];
    }
  }
  dp[ch] += sub[ch];
}
void dfs2(long long ch, long long par) {
  ans = max(ans, dp[ch]);
  for (auto i : gr[ch]) {
    if (i != par) {
      dp[ch] -= dp[i];
      dp[ch] -= sub[i];
      sub[ch] -= sub[i];
      sub[i] += sub[ch];
      dp[i] += sub[ch];
      dp[i] += dp[ch];
      dfs2(i, ch);
      dp[i] -= dp[ch];
      dp[i] -= sub[ch];
      sub[i] -= sub[ch];
      sub[ch] += sub[i];
      dp[ch] += sub[i];
      dp[ch] += dp[i];
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  dfs(1, 0);
  dfs2(1, 0);
  cout << ans;
  return 0;
}
