#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
istream &operator>>(istream &in, pair<T, U> &rhs) {
  in >> rhs.first;
  in >> rhs.second;
  return in;
}
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &rhs) {
  out << rhs.first;
  out << " ";
  out << rhs.second;
  return out;
}
template <class T, class U>
pair<T, U> operator+(pair<T, U> &a, pair<T, U> &b) {
  return pair<T, U>(a.first + b.first, a.second + b.second);
}
template <class T, class U>
pair<T, U> operator-(pair<T, U> &a, pair<T, U> &b) {
  return pair<T, U>(a.first - b.first, a.second - b.second);
}
template <class T>
istream &operator>>(istream &in, vector<T> &a) {
  for (auto &i : a) cin >> i;
  return in;
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &a) {
  for (auto &i : a) cout << i << " ";
  return out;
}
template <class T>
ostream &operator<<(ostream &out, const set<T> &a) {
  for (auto &i : a) cout << i << " ";
  return out;
}
template <class T>
ostream &operator<<(ostream &out, const unordered_set<T> &a) {
  for (auto &i : a) cout << i << " ";
  return out;
}
template <class T>
ostream &operator<<(ostream &out, const multiset<T> &a) {
  for (auto &i : a) cout << i << " ";
  return out;
}
template <class T, class U>
ostream &operator<<(ostream &out, const map<T, U> &a) {
  for (auto &i : a) cout << "(" << i.first << ", " << i.second << "(\n";
  return out;
}
template <class T, class U>
ostream &operator<<(ostream &out, const unordered_map<T, U> &a) {
  for (auto &i : a) cout << "(" << i.first << ", " << i.second << "(\n";
  return out;
}
void judge() {}
const long long N = 2e5 + 1;
long long dp[N];
vector<long long> g[N];
long long n;
long long val;
void dfs(long long u = 1, long long p = 0) {
  dp[u] = 1;
  for (auto i : g[u]) {
    if (i != p) {
      dfs(i, u);
      dp[u] += dp[i];
    }
  }
  val += dp[u];
}
long long ans;
void fun(long long u = 1, long long p = 0, long long sc = val) {
  ans = max(ans, sc);
  for (auto i : g[u]) {
    if (i != p) {
      fun(i, u, sc + n - 2 * dp[i]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  long long t = 1;
  judge();
  while (t--) {
    cin >> n;
    for (long long i = 1; i < n; i++) {
      long long a, b;
      cin >> a >> b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    dfs();
    fun();
    cout << ans << endl;
  }
}
