#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n;
vector<int> g[maxn], siz(maxn);
vector<long long> sum(maxn), dp(maxn);
void init(int x, int f = -1) {
  siz[x] = 1;
  for (int to : g[x]) {
    if (to == f) continue;
    init(to, x);
    siz[x] += siz[to];
    sum[x] += sum[to];
  }
  sum[x] = sum[x] + siz[x] - 1;
}
void dfs(int x, int f = -1) {
  if (g[x].size() == 1) {
    dp[x] = n;
    return;
  }
  for (int to : g[x]) {
    if (to == f) continue;
    dfs(to, x);
    dp[x] = max(dp[x], sum[x] - sum[to] - siz[to] + dp[to] + n - siz[to]);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    g[x].push_back(y), g[y].push_back(x);
  }
  if (n == 2) cout << 3 << endl;
  for (int i = 0; i < n; i++)
    if (g[i].size() > 1) {
      init(i);
      dfs(i);
      cout << dp[i] << endl;
      break;
    }
  return 0;
}
