#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
const double PI = acos(-1);
const double eps = (1e-9);
const long long int INF = 2e18;
const int M = (1e9) + 7;
const int N = (2e5) + 3;
vector<vector<int> > ad(N);
long long int sub[N], dp[N];
long long int ans = 0;
void dfs(int s, int p) {
  sub[s] = 1;
  for (auto a : ad[s]) {
    if (a != p) dfs(a, s), sub[s] += sub[a], dp[s] += dp[a];
  }
  dp[s] += sub[s];
}
void onceagain(int s, int p, int n) {
  ans = max(ans, dp[s]);
  long long int cur_root = dp[s], cur_child;
  for (auto a : ad[s]) {
    if (a == p) continue;
    cur_child = dp[a];
    dp[s] = cur_root - cur_child - sub[a];
    dp[a] = cur_root - 2 * sub[a] + n;
    onceagain(a, s, n);
    dp[s] = cur_root, dp[a] = cur_child;
  }
}
void solve() {
  int i, a, b, n;
  scanf("%d", &n);
  for (i = 0; i < n - 1; ++i) {
    scanf("%d%d", &a, &b);
    a--, b--;
    ad[a].emplace_back(b), ad[b].emplace_back(a);
  }
  dfs(0, -1);
  onceagain(0, -1, n);
  cout << ans << "\n";
}
void starting() {}
int main() {
  int t = 1;
  starting();
  while (t--) solve();
}
