#include <bits/stdc++.h>
using i64 = long long;
int16_t par[3000][3000], sub[3000][3000];
i64 memo[3000][3000];
std::vector<int16_t> g[3000];
int16_t dfs(const int v, const int p, const int r) {
  par[r][v] = p;
  sub[r][v] = 1;
  for (int to : g[v])
    if (to != p) sub[r][v] += dfs(to, v, r);
  return sub[r][v];
}
i64 rec(const int i, const int j) {
  if (i == j) return 0;
  if (memo[i][j]) return memo[i][j];
  return memo[i][j] = memo[j][i] =
             std::max(rec(i, par[i][j]), rec(par[j][i], j)) +
             1ll * sub[i][j] * sub[j][i];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; i++) dfs(i, -1, i);
  i64 ret = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) ret = std::max(ret, rec(i, j));
  printf("%lld\n", ret);
  return 0;
}
