#include <bits/stdc++.h>
using namespace std;
long long sum, n;
int u, v;
vector<vector<int> > adj;
long long numberOfNode[200010];
long long sumOfChild[200010];
long long solChild[200010];
long long minChild[200010];
long long getChild(int here = 1) {
  long long &ret = numberOfNode[here];
  ret = 1;
  for (int there : adj[here]) {
    if (numberOfNode[there] != 0) continue;
    ret += getChild(there);
  }
  return ret;
}
long long getSum(int here = 1) {
  long long &ret = sumOfChild[here];
  ret = numberOfNode[here];
  bool isLeaf = true;
  for (int there : adj[here]) {
    if (sumOfChild[there] != 0) continue;
    ret += getSum(there);
    minChild[here] = min(minChild[here], numberOfNode[there]);
    isLeaf = false;
  }
  if (isLeaf) minChild[here] = 0;
  return ret;
}
long long maxx = 0;
long long getSolution(int here, long long minus, long long sum, long long cnt,
                      long long nn) {
  long long &ret = solChild[here];
  ret = numberOfNode[here];
  bool isLeaf = true;
  for (int there : adj[here]) {
    long long nextSum = sum;
    if (solChild[there] != 0) continue;
    if (here == 1)
      nn = numberOfNode[there] + 1;
    else {
      nextSum += numberOfNode[there];
    }
    isLeaf = false;
    long long nextMinus = minus - numberOfNode[there];
    ret = getSolution(there, minus + numberOfNode[there], nextSum, cnt + 1, nn);
  }
  if (isLeaf) {
    maxx = max(maxx, n * cnt - sum - minus + (n + 1 - nn));
  }
  return ret;
}
int main() {
  scanf("%lld", &n);
  adj.resize(n + 1);
  memset(minChild, 0x3f, sizeof(minChild));
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  getChild();
  getSum();
  getSolution(1, 0, 0, 0, 0);
  for (int there : adj[1]) {
    sum += sumOfChild[there];
  }
  printf("%lld\n", sum + maxx);
}
