#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> graph[200005];
int subg[200005];
long long int fsum = 0LL;
long long int ans = LLONG_MIN;
int dfs(int node, int par) {
  int ret = 1;
  for (int i = 0; i < graph[node].size(); i++) {
    int ch = graph[node][i];
    if (ch != par) ret += dfs(ch, node);
  }
  subg[node] = ret;
  fsum += ret;
  return ret;
}
void katie(int node, int par, long long int csum) {
  for (int i = 0; i < graph[node].size(); i++) {
    int ch = graph[node][i];
    if (ch != par) {
      long long int chsum = csum + n - 2 * subg[ch];
      ans = max(ans, chsum);
      katie(ch, node, chsum);
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(0, -1);
  ans = fsum;
  katie(0, -1, fsum);
  cout << ans << "\n";
  return 0;
}
