#include <bits/stdc++.h>
using namespace std;
vector<int> node[500000];
long long n;
long long dp[500000], sz[500000];
long long ans = 1e18;
long long f(long long n) { return n * (n + 1) / 2; }
void dfs(int p, int par = -1) {
  sz[p] = 1;
  for (int i : node[p]) {
    if (i == par) continue;
    dfs(i, p);
    sz[p] += sz[i];
  }
  dp[p] = f(sz[p]);
  vector<pair<long long, long long>> v;
  for (int i : node[p]) {
    if (i == par) continue;
    dp[p] = min(dp[p], f(sz[p] - sz[i]) + dp[i]);
    v.emplace_back(sz[i], dp[i] * 2 + sz[i] * sz[i]);
  }
  sort(v.begin(), v.end());
  vector<double> xs;
  vector<pair<long long, long long>> s;
  xs.push_back(-1e18);
  s.emplace_back(0, 0);
  auto cross = [&](pair<long long, long long> a, pair<long long, long long> b) {
    assert(a.first != b.first);
    return max(-double(a.second - b.second) / (a.first - b.first), -0.9e18);
  };
  auto query = [&](long long first) {
    int i = upper_bound(xs.begin(), xs.end(), (double)first) - xs.begin() - 1;
    return s[i].first * first + s[i].second;
  };
  auto append = [&](long long a, long long b) {
    pair<long long, long long> m(a, b);
    assert(m.first <= s.back().first);
    if (m.first == s.back().first) {
      assert(s.size() > 1);
      if (s.back().second < m.second) return;
      s.pop_back();
      xs.pop_back();
    }
    assert(s.size() == xs.size());
    while (cross(s.back(), m) <= xs.back()) s.pop_back(), xs.pop_back();
    xs.push_back(cross(s.back(), m));
    s.push_back(m);
  };
  for (auto v : v) {
    long long n_ = n - v.first;
    long long score =
        v.second + n * n + n - (2 * n + 1) * v.first + query(2 * n_ + 1);
    ans = min(ans, score / 2);
    append(-v.first, v.second);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  dfs(0);
  cout << n * n - ans << endl;
}
