#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
long long rootans = 0;
vector<long long> dp1(200001, 1);
vector<long long> dp2(200001, 1);
vector<int> adj[200001];
void dfs(int u, int p) {
  for (int i : adj[u]) {
    if (i != p) {
      dfs(i, u);
      dp1[u] += dp1[i];
    }
  }
}
void dfs2(int u, int p) {
  rootans += dp1[u];
  for (int i : adj[u]) {
    if (i != p) {
      dfs2(i, u);
    }
  }
}
void dfs3(int u, int p) {
  for (int i : adj[u]) {
    if (i != p) {
      dp2[i] = dp2[u] - dp1[i] + dp1[1] - dp1[i];
      ans = max(ans, dp2[i]);
      dfs3(i, u);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0);
  dfs2(1, 0);
  dp2[1] = rootans;
  dfs3(1, 0);
  cout << ans << endl;
}
