#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int next, to;
} edge[3005 << 1];
int head[3005], cnt = 1, n, par[3005][3005], sub[3005][3005], rt;
long long dp[3005][3005], ans;
inline void add(int x, int y) {
  edge[cnt].to = y, edge[cnt].next = head[x], head[x] = cnt++;
}
void DFS(int x, int fa) {
  par[rt][x] = fa, sub[rt][x] = 1;
  for (int i = head[x]; i; i = edge[i].next) {
    if (edge[i].to != fa) DFS(edge[i].to, x), sub[rt][x] += sub[rt][edge[i].to];
  }
}
long long DP(int x, int y) {
  if (x == y) return 0;
  if (~dp[x][y]) return dp[x][y];
  return dp[y][x] = dp[x][y] = 1ll * sub[x][y] * sub[y][x] +
                               max(DP(par[y][x], y), DP(x, par[x][y]));
}
int main() {
  scanf("%d", &n), memset(dp, -1, sizeof(dp));
  for (int i = 1, x, y; i < n; i++) scanf("%d%d", &x, &y), add(x, y), add(y, x);
  for (int i = 1; i <= n; i++) rt = i, DFS(i, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) ans = max(ans, DP(i, j));
  }
  printf("%lld", ans);
  return 0;
}
