#include <bits/stdc++.h>
using namespace std;
vector<int> g[500005];
int sz[500005];
bool vis[500005];
int n;
const long long is_query = -(1LL << 60);
struct Line {
  long long m, b;
  mutable function<const Line*()> succ;
  bool operator<(const Line& rhs) const {
    if (rhs.b != is_query) return m < rhs.m;
    const Line* s = succ();
    if (!s) return 0;
    long long x = rhs.m;
    return b - s->b < (s->m - m) * x;
  }
};
struct HullDynamic : public multiset<Line> {
  void init() { clear(); }
  bool bad(iterator y) {
    auto z = next(y);
    if (y == begin()) {
      if (z == end()) return 0;
      return y->m == z->m && y->b <= z->b;
    }
    auto x = prev(y);
    if (z == end()) return y->m == x->m && y->b <= x->b;
    return (x->b - y->b) * (z->m - y->m) >= (y->b - z->b) * (y->m - x->m);
  }
  void insert_line(long long m, long long b) {
    m = -m, b = -b;
    auto y = insert({m, b});
    y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
    if (bad(y)) {
      erase(y);
      return;
    }
    while (next(y) != end() && bad(next(y))) erase(next(y));
    while (y != begin() && bad(prev(y))) erase(prev(y));
  }
  long long eval(long long x) {
    if (size() == 0) return 1e18;
    auto l = *lower_bound((Line){x, is_query});
    return -(l.m * x + l.b);
  }
} dp2;
long long ans = 1e18;
long long dp[500005];
void dfs(int u, int p = 0) {
  sz[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v != p) {
      dfs(v, u);
      sz[u] += sz[v];
    }
  }
  dp2.init();
  dp[u] = sz[u] * 1ll * (sz[u] - 1);
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v != p) {
      long long m = 2 * sz[v];
      long long c = n * 1ll * n - n + sz[v] + sz[v] * 1ll * sz[v] -
                    2 * 1ll * n * sz[v] + dp[v];
      long long add = sz[v] + sz[v] * 1ll * sz[v] - 2 * 1ll * n * sz[v] + dp[v];
      ans = min(ans, dp2.eval(sz[v]) + add);
      dp2.insert_line(m, c);
      dp[u] = min(dp[u], dp[v] + (sz[u] - sz[v]) * 1ll * (sz[u] - sz[v] - 1));
      ans = min(ans, dp[v] + (n - sz[v]) * 1ll * (n - sz[v] - 1));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  dfs(1);
  printf("%lld\n", n * 1ll * (n - 1) / 2 * 2 - ans / 2);
}
