#include <bits/stdc++.h>
using namespace std;
void printvector(std::vector<long long> v) {
  for (long long i = 0; i < v.size(); ++i) {
    cout << v[i] << " ";
  }
  cout << "" << endl;
}
void printarray(long long a[], long long n) {
  for (long long i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
  cout << "" << endl;
}
vector<long long> dfs1(std::vector<long long> v[], long long s, bool visited[],
                       long long d[], long long u[], long long t[],
                       long long si[]) {
  visited[s] = true;
  si[s] = 1;
  for (long long i = 0; i < v[s].size(); ++i) {
    if (!visited[v[s][i]]) {
      visited[v[s][i]] = true;
      vector<long long> temp = dfs1(v, v[s][i], visited, d, u, t, si);
      d[s] += temp[0];
      si[s] += temp[1];
    }
  }
  vector<long long> tr;
  tr.push_back(d[s] + si[s]);
  tr.push_back(si[s]);
  return tr;
}
void dfs2(std::vector<long long> v[], long long s, bool visited[],
          long long d[], long long u[], long long t[], long long si[],
          long long up, long long n) {
  visited[s] = true;
  u[s] = up;
  t[s] = n + d[s] + u[s];
  for (long long i = 0; i < v[s].size(); ++i) {
    if (!visited[v[s][i]]) {
      long long ad = v[s][i];
      visited[v[s][i]] = true;
      dfs2(v, v[s][i], visited, d, u, t, si,
           d[s] - (si[ad] + d[ad]) + u[s] + n - si[ad], n);
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  std::vector<long long> v[n];
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long d[n];
  memset(d, 0, sizeof(d));
  long long u[n];
  memset(u, 0, sizeof(u));
  long long t[n];
  memset(t, 0, sizeof(t));
  long long si[n];
  memset(si, 0, sizeof(si));
  bool visited[n];
  for (long long i = 0; i < n; ++i) {
    visited[i] = false;
  }
  dfs1(v, 0, visited, d, u, t, si);
  for (long long i = 0; i < n; ++i) {
    visited[i] = false;
  }
  dfs2(v, 0, visited, d, u, t, si, 0, n);
  long long ans = INT_MIN;
  for (long long i = 0; i < n; ++i) {
    ans = max(ans, t[i]);
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
