#include <bits/stdc++.h>
using ld = double;
using namespace std;
const double eps = (1e-12);
const int INF = 2e9 + 9;
const int logn = 21;
const double pi = acos(-1.0);
long long dp[3005][3005];
long long sz[3005][3005];
int fa[3005][3005];
int n;
vector<vector<int> > g(3005);
void dfs(int u, int p, int root) {
  fa[root][u] = p;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == p) continue;
    dfs(v, u, root);
    sz[root][u] += sz[root][v];
  }
  sz[root][u]++;
}
long long solve(int x, int y) {
  if (x == y) return 0;
  if (dp[x][y] != -1) return dp[x][y];
  dp[x][y] = sz[y][x] * sz[x][y] + max(solve(fa[y][x], y), solve(x, fa[x][y]));
  return dp[x][y];
}
signed main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, -1, i);
  }
  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", ans);
  return 0;
}
