#include <bits/stdc++.h>
using namespace std;
using LL = long long;
vector<int> E[200005];
int n, x, y, sz[200005];
LL ans, cnt;
void dfs(int x, int fa, int dep) {
  cnt += dep;
  sz[x] = 1;
  for (int &j : E[x])
    if (j != fa) dfs(j, x, dep + 1), sz[x] += sz[j];
}
void dfs2(int x, int fa, LL cnt) {
  for (int &j : E[x])
    if (j != fa) {
      ans = max(ans, cnt - sz[j] + n - sz[j]);
      dfs2(j, x, cnt - sz[j] + n - sz[j]);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++)
    scanf("%d%d", &x, &y), E[x].push_back(y), E[y].push_back(x);
  dfs(1, 0, 0);
  ans = cnt;
  dfs2(1, 0, cnt);
  printf("%lld", ans + n);
  return 0;
}
