#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int n, par[N];
vector<int> ve[N];
pair<long long, int> p[N];
long long ans = 0;
void dfs(int u) {
  p[u] = {(long long)0, 1};
  for (int v : ve[u]) {
    if (v != par[u]) {
      par[v] = u;
      dfs(v);
      p[u].first += p[v].first;
      p[u].second += p[v].second;
    }
  }
  p[u].first += p[u].second;
}
void dfs1(int u) {
  for (int v : ve[u]) {
    if (v != par[u]) {
      p[v].first =
          p[u].first - (long long)2 * (long long)p[v].second + (long long)n;
      ans = max(ans, p[v].first);
      dfs1(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int u, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    ve[u].push_back(v);
    ve[v].push_back(u);
  }
  dfs(1);
  ans = max(ans, p[1].first);
  dfs1(1);
  cout << ans << '\n';
}
