#include <bits/stdc++.h>
const long long INF = 1e9;
const double E = 1e-10;
const long long P = 1e9 + 7;
const long long Q = 31;
using namespace std;
void hello() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void show(vector<long long>& arr) {
  for (auto i : arr) cout << i << " ";
  cout << "\n";
}
void show(vector<vector<long long>>& arr) {
  for (auto i : arr) show(i);
  cout << "\n";
}
long long n;
void dfs1(long long v, long long p, vector<vector<long long>>& graph,
          vector<long long>& sum, vector<long long>& sz) {
  sz[v] = 1;
  for (auto to : graph[v])
    if (to != p) dfs1(to, v, graph, sum, sz);
  for (auto to : graph[v])
    if (to != p) sz[v] += sz[to];
  for (auto to : graph[v])
    if (to != p) sum[v] += sum[to];
  sum[v] += sz[v];
}
void dfs2(long long v, long long p, vector<vector<long long>>& graph,
          vector<long long>& sum, vector<long long>& sz, vector<long long>& res,
          long long val) {
  for (auto to : graph[v])
    if (to != p) val += sum[to];
  bool flag = 0;
  for (auto to : graph[v])
    if (to != p) {
      dfs2(to, v, graph, sum, sz, res, val + n - sz[to] - sum[to]);
      flag = 1;
    }
  if (!flag) res[v] = val + n;
}
signed main() {
  hello();
  cin >> n;
  vector<vector<long long>> graph(n);
  for (long long i = 0; i < n - 1; ++i) {
    long long x, y;
    cin >> x >> y;
    graph[x - 1].push_back(y - 1);
    graph[y - 1].push_back(x - 1);
  }
  vector<long long> sum(n);
  vector<long long> sz(n);
  dfs1(0, -1, graph, sum, sz);
  vector<long long> res(n);
  dfs2(0, -1, graph, sum, sz, res, 0);
  long long ares = sum[0];
  for (long long i = 0; i < n; ++i) ares = max(ares, res[i]);
  cout << ares << "\n";
}
