#include <bits/stdc++.h>
using namespace std;
template <class T>
constexpr T lcm(T m, T n) {
  return m / __gcd(m, n) * n;
}
template <typename I>
void join(ostream &ost, I s, I t, string d = " ") {
  for (auto i = s; i != t; ++i) {
    if (i != s) ost << d;
    ost << *i;
  }
  ost << endl;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &a : v) is >> a;
  return is;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
bool chmin(T &a, const U &b) {
  return (a > b ? a = b, true : false);
}
template <typename T, typename U>
bool chmax(T &a, const U &b) {
  return (a < b ? a = b, true : false);
}
template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v) {
  fill((U *)a, (U *)(a + N), v);
}
template <typename Cost = int>
class Edge {
 public:
  int from, to;
  Cost cost;
  Edge() {}
  Edge(int to, Cost cost) : to(to), cost(cost) {}
  Edge(int from, int to, Cost cost) : from(from), to(to), cost(cost) {}
  Edge rev() const { return Edge(to, from, cost); }
  friend ostream &operator<<(ostream &os, const Edge &e) {
    os << "(FROM: " << e.from << ","
       << "TO: " << e.to << ","
       << "COST: " << e.cost << ")";
    return os;
  }
};
template <typename T>
using Graph = vector<vector<Edge<T>>>;
template <typename T>
using Tree = vector<vector<Edge<T>>>;
template <typename C, typename T>
void add_edge(C &g, int from, int to, T w) {
  g[from].push_back(Edge<T>(from, to, w));
}
template <typename C, typename T>
void add_undirected(C &g, int a, int b, T w) {
  g[a].push_back(Edge<T>(a, b, w));
  g[b].push_back(Edge<T>(b, a, w));
}
long long int sub[202000];
long long int dp[202000];
long long int dp2[202000];
void dfs(const Tree<int> &tree, int cur, int par) {
  sub[cur] = 1;
  for (auto &e : tree[cur]) {
    if (e.to == par) continue;
    dfs(tree, e.to, cur);
    sub[cur] += sub[e.to];
    dp[cur] += dp[e.to] + sub[e.to];
  }
}
void dfs2(const Tree<int> &tree, int cur, int par) {
  for (auto &e : tree[cur]) {
    if (e.to == par) continue;
    dp2[e.to] = dp2[cur] - sub[e.to] + (tree.size() - sub[e.to]);
    dfs2(tree, e.to, cur);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n) {
    Tree<int> tree(n);
    vector<int> deg(n);
    for (long long int i = (0); i < (n - 1); ++i) {
      int u, v;
      cin >> u >> v;
      add_undirected(tree, u - 1, v - 1, 1);
      deg[u - 1]++;
      deg[v - 1]++;
    }
    fill_array(sub, 0);
    fill_array(dp, 0);
    fill_array(dp2, 0);
    dfs(tree, 0, -1);
    dp2[0] = dp[0];
    dfs2(tree, 0, -1);
    long long int ans = 0;
    for (long long int i = (0); i < (n); ++i) {
      chmax(ans, dp2[i] + n);
    }
    cout << ans << endl;
  }
  return 0;
}
