#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
const int MN = 500005, inf = 1000000005, mod = 1000000007;
const long long INF = 1000000000000000005LL;
long long dp[MN];
int pod[MN];
vector<int> G[MN];
int n;
long long ans = INF;
inline long long po2(long long x) { return ((x * (x - 1LL)) >> 1); }
void dfs(int x, int p) {
  pod[x] = 1;
  for (auto v : G[x])
    if (v != p) {
      dfs(v, x);
      pod[x] += pod[v];
    }
  dp[x] = po2(pod[x]);
  for (auto v : G[x])
    if (v != p) dp[x] = min(dp[x], po2(pod[x] - pod[v]) + dp[v]);
  vector<pair<int, long long> > naj;
  for (auto v : G[x])
    if (v != p) naj.push_back({pod[v], dp[v]});
  sort((naj).begin(), (naj).end());
  int pos = 2;
  int s = naj.size();
  for (int i = 2; i < s; ++i) {
    if (naj[i].first == naj[pos - 1].first &&
        naj[i].first == naj[pos - 2].first)
      continue;
    naj[pos++] = naj[i];
  }
  s = min(s, pos);
  for (int i = 0; i < s; ++i)
    for (int j = i + 1; j < s; ++j)
      ans = min(ans, po2(n - naj[i].first - naj[j].first) +
                         (long long)naj[i].second + (long long)naj[j].second);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  if (n == 2) {
    printf("2");
    return 0;
  }
  int root = 1;
  for (int i = 1; i <= n; ++i)
    if (G[i].size() > 1) {
      root = i;
      break;
    }
  dfs(root, 0);
  ans = 1LL * n * (n - 1) - ans;
  printf("%lld", ans);
}
