#include <bits/stdc++.h>
using namespace std;
int n, r;
int p[600000], s[600000];
long long dp[600000];
vector<int> G[600000];
map<int, vector<long long> > c[600000];
long long res = 0;
void magic(long long dp1, long long sz1, long long dp2, long long sz2) {
  long long sq = dp1 + dp2 + (n - sz1 - sz2) * (n - sz1 - sz2);
  sq = (sq - n) / 2;
  res = max(res, (long long)n * (n - 1) - sq);
}
void dfs(int v) {
  s[v] = 1;
  for (int u : G[v]) {
    if (u == p[v]) continue;
    p[u] = v;
    dfs(u);
    s[v] += s[u];
    c[v][s[u]].push_back(dp[u]);
  }
  if (s[v] == 1)
    dp[v] = 1;
  else {
    dp[v] = 1e18;
    for (int u : G[v]) {
      if (u == p[v]) continue;
      dp[v] = min(dp[v], dp[u] + (long long)(s[v] - s[u]) * (s[v] - s[u]));
    }
    for (auto x : c[v]) {
      if (x.second.size() <= 1) continue;
      sort(x.second.begin(), x.second.end());
      magic(x.second[0], x.first, x.second[1], x.first);
    }
    for (auto x : c[v]) {
      for (auto y : c[v]) {
        if (x.first != y.first)
          magic(x.second[0], x.first, y.second[0], y.first);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << setprecision(12) << fixed;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  if (n == 2) {
    cout << 2 << endl;
    return 0;
  }
  while (G[r].size() < 2) {
    ++r;
  }
  p[r] = r;
  dfs(r);
  cout << res << endl;
  return 0;
}
