#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n;
vector<int> g[maxn];
vector<long long> dp(maxn), sz(maxn);
void init(int x, int f) {
  sz[x] = 1;
  for (auto to : g[x]) {
    if (to == f) continue;
    init(to, x);
    sz[x] += sz[to];
    dp[x] += dp[to];
  }
  dp[x] += sz[x];
}
long long ans;
void dfs(int x, int f) {
  for (auto to : g[x]) {
    if (to == f) continue;
    dp[to] = dp[x] + n - 2 * sz[to];
    ans = max(ans, dp[to]);
    dfs(to, x);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y), g[y].push_back(x);
  }
  init(1, 0);
  dfs(1, 0);
  cout << ans << '\n';
  return 0;
}
