#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
const int N = 3e3 + 5;
int n, u, v, fa[N][N], cnt[N][N];
long long dp[N][N];
vector<int> E[N];
void add_edges(int x, int y) {
  E[x].push_back(y);
  E[y].push_back(x);
}
void dfs(int u, int root, int f) {
  fa[root][u] = f;
  cnt[root][u] = 1;
  for (int i = (0); i <= (E[u].size() - 1); i++) {
    int v = E[u][i];
    if (v == f) continue;
    dfs(v, root, u);
    cnt[root][u] += cnt[root][v];
  }
}
long long solve(int x, int y) {
  if (x == y) return 0;
  if (dp[x][y] != -1) return dp[x][y];
  dp[x][y] = max(dp[x][y], cnt[y][x] * cnt[x][y] +
                               max(solve(fa[y][x], y), solve(x, fa[x][y])));
  return dp[x][y];
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n - 1); i++) {
    scanf("%d%d", &u, &v);
    add_edges(u, v);
  }
  for (int i = (1); i <= (n); i++) dfs(i, i, -1);
  memset(dp, -1, sizeof(dp));
  long long ans = 0;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++) ans = max(ans, solve(i, j));
  printf("%lld\n", ans);
  return 0;
}
