#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 6;
vector<vector<int> > adj(N);
long long int dp[N], s[N], ans = 0;
void cal(int u, int p = -1) {
  s[u] = 1;
  for (auto v : adj[u]) {
    if (v == p) continue;
    cal(v, u);
    s[u] += s[v];
    dp[u] += dp[v];
  }
  dp[u] += s[u];
}
void dfs(int u, int p = -1) {
  ans = max(ans, dp[u]);
  for (auto v : adj[u]) {
    if (v == p) continue;
    s[u] -= s[v];
    dp[u] -= s[v];
    dp[u] -= dp[v];
    s[v] += s[u];
    dp[v] += s[u];
    dp[v] += dp[u];
    dfs(v, u);
    dp[v] -= dp[u];
    dp[v] -= s[u];
    s[v] -= s[u];
    dp[u] += dp[v];
    dp[u] += s[v];
    s[u] += s[v];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  cal(1);
  dfs(1);
  cout << ans;
  return 0;
}
