#include <bits/stdc++.h>
using namespace std;
const int64_t MAXN = 1e5 + 5, mod = 1e9 + 7;
int64_t n, root;
vector<vector<int64_t>> g;
vector<int64_t> sz, sum, dp;
int64_t dfs1(int64_t v, int64_t p) {
  if (g[v].size() == 1 && g[v][0] == p) return sz[v] = 1;
  int64_t ans = 0;
  for (auto to : g[v])
    if (to != p) ans += dfs1(to, v);
  return sz[v] = ans + 1;
}
int64_t dfs2(int64_t v, int64_t p) {
  if (g[v].size() == 1 && g[v][0] == p) return sum[v] = 0;
  int64_t ans = 0;
  for (auto to : g[v])
    if (to != p) ans += dfs2(to, v) + sz[to];
  return sum[v] = ans;
}
void dfs3(int64_t v, int64_t p) {
  if (v == root)
    dp[v] = n + sum[v];
  else {
    dp[v] = n + dp[p] - (sum[v] + sz[v] + sz[v]) + sum[v];
  }
  for (auto to : g[v])
    if (to != p) dfs3(to, v);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  g.resize(n);
  sz.resize(n);
  sum.resize(n);
  dp.resize(n);
  for (int64_t i = 0; i < n - 1; i++) {
    int64_t u, v;
    cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  root = 0;
  dfs1(root, -1);
  dfs2(root, -1);
  dfs3(root, -1);
  int64_t ans = -1;
  for (int64_t i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << ans << '\n';
}
