#include <bits/stdc++.h>
using namespace std;
static const int NMAX = 2 * 1e5 + 5;
int n;
int f[NMAX];
long long dp[NMAX];
long long sz[NMAX];
vector<int> graph[NMAX];
void getSz(int node) {
  sz[node] = 1;
  for (auto x : graph[node]) {
    if (sz[x]) continue;
    getSz(x);
    sz[node] += sz[x];
  }
  return;
}
void getDp(int node) {
  dp[node] = sz[node];
  for (auto x : graph[node]) {
    if (dp[x]) continue;
    getDp(x);
    dp[node] += dp[x];
  }
  return;
}
long long ans;
void getAns(int node) {
  f[node] = 1;
  ans = max(dp[node], ans);
  for (auto x : graph[node]) {
    if (f[x]) continue;
    dp[node] -= (dp[x] + sz[x]);
    sz[node] -= sz[x];
    dp[x] += (dp[node] + sz[node]);
    sz[x] += sz[node];
    getAns(x);
    dp[x] -= (dp[node] + sz[node]);
    sz[x] -= sz[node];
    dp[node] += (dp[x] + sz[x]);
    sz[node] += sz[x];
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  getSz(1);
  getDp(1);
  getAns(1);
  cout << ans << '\n';
}
