#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
vector<long long> g[N];
long long Subtree[N], dp[N][2], Children[N], Parent[N];
void dfs(long long node, long long par) {
  Parent[node] = par;
  Subtree[node] = 1;
  Children[node] = 0;
  for (long long i = 0; i < g[node].size(); i++) {
    if (g[node][i] != par) {
      dfs(g[node][i], node);
      Subtree[node] += Subtree[g[node][i]];
      dp[node][0] += dp[g[node][i]][0];
      Children[node] += dp[g[node][i]][0];
    }
  }
  dp[node][0] += Subtree[node];
}
void dfs2(long long node, long long par, long long n) {
  if (node == 1) {
    dp[node][1] = 0;
  } else {
    dp[node][1] = dp[Parent[node]][1] + n - Subtree[node] +
                  Children[Parent[node]] - dp[node][0];
  }
  for (long long i = 0; i < g[node].size(); i++) {
    if (g[node][i] != par) dfs2(g[node][i], node, n);
  }
}
void Solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (long long i = 0; i < N; i++) {
    Subtree[i] = 0;
    dp[i][0] = dp[i][1] = 0;
    Children[i] = 0;
    Parent[i] = -1;
  }
  dfs(1, -1);
  dp[1][1] = 0;
  dfs2(1, -1, n);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans = max(ans, dp[i][0] + dp[i][1] + n - Subtree[i]);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Solve();
  return 0;
}
