#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long INF = 0x3f3f3f3f;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5;
vector<long long> g[N], sz(N), dp(N);
long long n, ans;
void dfs_size(long long u, long long p) {
  sz[u] = 1;
  for (long long v : g[u]) {
    if (v != p) {
      dfs_size(v, u);
      sz[u] += sz[v];
      dp[u] += dp[v];
    }
  }
  dp[u] += sz[u];
}
void dfs(long long u, long long p) {
  ans = max(ans, dp[u]);
  for (long long v : g[u]) {
    if (v != p) {
      dp[u] -= dp[v];
      dp[u] -= sz[v];
      sz[u] -= sz[v];
      dp[v] += dp[u];
      dp[v] += sz[u];
      sz[v] += sz[u];
      dfs(v, u);
      dp[v] -= dp[u];
      dp[v] -= sz[u];
      sz[v] -= sz[u];
      dp[u] += dp[v];
      dp[u] += sz[v];
      sz[u] += sz[v];
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  dfs_size(1, -1);
  dfs(1, -1);
  cout << ans << "\n";
  return 0;
}
