#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
inline T russian(T a, T b, T mod) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = (a + a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
inline T sub(T a, T b, T mod) {
  return ((a - b) + mod) % mod;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <typename T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
long double e = 2.7182818284590452353602874713526624;
long double PI = acos(-1);
long double eps = 1e-11;
const long long T = 1 << 19;
const long long INF = 1e9 + 7;
const long long BIG_INF = 1e18 + 5;
const long long N = 1e6 + 7;
const long long M = 2007;
long long n, m, k;
vector<vector<int> > G(N);
long long rozmiar[N];
long long dp[N];
vector<int> droga;
void dfs(int start, int pre = 0) {
  droga.push_back(start);
  rozmiar[start] = 1;
  for (auto &u : G[start]) {
    if (u == pre) continue;
    dfs(u, start);
    droga.push_back(start);
    dp[start] += dp[u];
    rozmiar[start] += rozmiar[u];
  }
  dp[start] += rozmiar[start];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1);
  long long ans = 0;
  for (int i = 1; i < (int)(droga).size(); i++) {
    int nowy = droga[i];
    int stary = droga[i - 1];
    dp[stary] -= (dp[nowy] + rozmiar[nowy]);
    rozmiar[stary] -= rozmiar[nowy];
    dp[nowy] += (dp[stary] + rozmiar[stary]);
    rozmiar[nowy] += rozmiar[stary];
    setmax(ans, dp[nowy]);
  }
  cout << ans << '\n';
}
