#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
long long dp[N][N], siz[N][N], fa[N][N], n, rt;
vector<long long> e[N];
void dfs(long long u) {
  siz[rt][u] = 1;
  for (auto v : e[u]) {
    if (v == fa[rt][u]) continue;
    fa[rt][v] = u;
    dfs(v);
    siz[rt][u] += siz[rt][v];
    if (!dp[u][v]) dp[u][v] = dp[v][u] = siz[rt][v] * (n - siz[rt][v]);
  }
}
long long solve(long long u, long long v) {
  if (dp[u][v]) return dp[u][v];
  dp[u][v] = dp[v][u] =
      max(solve(u, fa[u][v]), solve(v, fa[v][u])) + siz[v][u] * siz[u][v];
  return dp[u][v];
}
int main() {
  long long m, i, j, k, ans = 0, num, sum, u, v;
  scanf("%lld", &n);
  for (i = 1; i <= n - 1; i++)
    scanf("%lld%lld", &u, &v), e[u].push_back(v), e[v].push_back(u);
  for (i = 1; i <= n; i++) rt = i, dfs(i);
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++)
      dp[i][j] = solve(i, j), ans = max(ans, dp[i][j]);
  printf("%lld\n", ans);
  return 0;
}
