#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 2e5 + 5;
long long int sz[maxn], dp[maxn], ans[maxn];
vector<long long int> g[maxn];
long long int n;
long long int dp1(long long int node, long long int parent) {
  sz[node] = 1;
  for (auto& itr : g[node])
    if (itr != parent) sz[node] += dp1(itr, node);
  return sz[node];
}
long long int dp2(long long int node, long long int parent) {
  dp[node] = sz[node];
  for (auto& itr : g[node])
    if (itr != parent) dp[node] += dp2(itr, node);
  return dp[node];
}
void dp3(long long int node, long long int parent,
         long long int fromParent = 0) {
  if (parent == -1)
    ans[node] = dp[node];
  else
    ans[node] = n - 2 * sz[node] + ans[parent];
  for (auto& itr : g[node])
    if (itr != parent) dp3(itr, node);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long int i = 1; i < n; i++) {
    long long int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dp1(1, -1);
  dp2(1, -1);
  dp3(1, -1);
  long long int answer = 0;
  for (long long int i = 1; i <= n; i++) answer = max(answer, ans[i]);
  cout << answer;
  return 0;
}
