#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007LL;
const int N = 5e5 + 10;
const long long Inf = 2242545357980376863LL;
const long long Log = 30;
vector<int> G[N];
int n;
long long dp[N], sz[N];
long long C2(long long x) { return x * (x - 1) / 2ll; }
long long ans = Inf;
void DFS(int u, int p) {
  vector<pair<long long, long long> > V;
  sz[u] = 1;
  for (auto adj : G[u]) {
    if (adj != p) {
      DFS(adj, u);
      sz[u] += sz[adj];
      V.push_back({sz[adj], dp[adj]});
    }
  }
  dp[u] = C2(sz[u]);
  for (auto [s, d] : V) dp[u] = min(dp[u], d + C2(sz[u] - s));
  sort(V.begin(), V.end());
  vector<pair<long long, long long> > V2;
  if (!V.empty()) V2.push_back(V[0]);
  for (int i = 1; i < (int)V.size(); i++) {
    if (V[i].first != V[i - 1].first) V2.push_back(V[i]);
    ans = min(ans, C2(n - V[i - 1].first - V[i].first) + V[i].second +
                       V[i - 1].second);
  }
  for (int i = 0; i < (int)V2.size(); i++)
    for (int j = i + 1; j < (int)V2.size(); j++)
      ans = min(
          ans, C2(n - V2[i].first - V2[j].first) + V2[i].second + V2[j].second);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int u, v;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  DFS(1, -1);
  ans = min(ans, dp[1]);
  cout << 2 * C2(n) - ans << '\n';
  return 0;
}
