#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25;
int n;
long long ans;
int siz[N];
long long dp[N];
vector<int> adj[N];
int calc_size(int u, int p = -1) {
  siz[u] = 1;
  for (auto v : adj[u])
    if (v != p) siz[u] += calc_size(v, u);
  return siz[u];
}
long long calc_dp(int u, int p = -1) {
  dp[u] = siz[u];
  for (auto v : adj[u])
    if (v != p) dp[u] += calc_dp(v, u);
  return dp[u];
}
void dfs(int u, int p = -1) {
  ans = max(ans, dp[u]);
  for (auto v : adj[u])
    if (v != p) {
      dp[u] -= dp[v];
      dp[u] -= siz[v];
      siz[u] -= siz[v];
      siz[v] += siz[u];
      dp[v] += siz[u];
      dp[v] += dp[u];
      dfs(v, u);
      dp[v] -= dp[u];
      dp[v] -= siz[u];
      siz[v] -= siz[u];
      siz[u] += siz[v];
      dp[u] += siz[v];
      dp[u] += dp[v];
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  ans = 0;
  calc_size(0);
  calc_dp(0);
  dfs(0);
  cout << ans << endl;
}
