#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
long long dp[N][N], fa[N][N], siz[N][N];
vector<int> son[N];
void finds(int rt, int x) {
  siz[rt][x] = 1;
  for (int ne : son[x]) {
    if (ne == fa[rt][x]) continue;
    fa[rt][ne] = x;
    finds(rt, ne);
    siz[rt][x] += siz[rt][ne];
  }
}
long long dfs(int l, int r) {
  if (l == r) return 0;
  if (~dp[l][r]) return dp[l][r];
  return dp[l][r] =
             siz[r][l] * siz[l][r] + max(dfs(fa[r][l], r), dfs(l, fa[l][r]));
}
int main() {
  memset(dp, -1, sizeof(dp));
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i < n; i++)
    scanf("%d%d", &x, &y), son[x].push_back(y), son[y].push_back(x);
  for (int i = 1; i <= n; i++) finds(i, i);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) ans = max(ans, dfs(i, j));
  printf("%lld\n", ans);
  return 0;
}
