#include <bits/stdc++.h>
const double pi = 4.0 * atan(1.0);
const double e = exp(1.0);
const int maxn = 3e5 + 8;
const long long mod = 1e9 + 7;
const unsigned long long base = 1e7 + 7;
using namespace std;
vector<long long> g[maxn];
long long c[maxn], s[maxn];
long long ans = 0;
void dfs(int u, int fa) {
  s[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    if (g[u][i] != fa) {
      dfs(g[u][i], u);
      s[u] += s[g[u][i]];
      c[u] += c[g[u][i]];
    }
  }
  c[u] += s[u];
}
void dfs2(int u, int fa) {
  if (fa != 0) {
    c[u] = s[1] + c[fa] - s[u] - s[u];
  }
  ans = max(ans, c[u]);
  for (int i = 0; i < g[u].size(); i++) {
    if (g[u][i] != fa) {
      dfs2(g[u][i], u);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  dfs2(1, 0);
  cout << ans << endl;
}
