#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 3010;
vector<int> e[N];
int sum[N][N];
int f[N][N];
long long dp[N][N];
void dfs(int p, int pre, int rt) {
  if (pre == -1)
    f[p][rt] = p;
  else
    f[p][rt] = pre;
  sum[p][rt] = 1;
  for (auto v : e[p]) {
    if (v == pre) continue;
    dfs(v, p, rt);
    sum[p][rt] += sum[v][rt];
  }
}
long long cal(int i, int j) {
  if (dp[i][j] == -1) {
    cal(i, f[j][i]);
    cal(j, f[i][j]);
    dp[i][j] = max(dp[i][f[j][i]], dp[j][f[i][j]]);
    dp[i][j] += sum[i][j] * sum[j][i];
    dp[j][i] = dp[i][j];
  }
  return dp[i][j];
}
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  while (cin >> n) {
    for (int i = (1); i < (n); i++) {
      int x, y;
      cin >> x >> y;
      e[x].push_back(y);
      e[y].push_back(x);
    }
    memset(sum, 0, sizeof(sum));
    memset(dp, -1, sizeof(dp));
    for (int i = (1); i < (n + 1); i++) {
      dp[i][i] = 0;
      dfs(i, -1, i);
    }
    long long ans = 0;
    for (int i = (1); i < (n + 1); i++)
      for (int j = (i + 1); j < (n + 1); j++) {
        cal(i, j);
        ans = max(ans, dp[i][j]);
      }
    cout << ans << '\n';
  }
  return 0;
}
