#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const long long N = 3007;
long long n, cnt, ans;
long long head[N];
long long dp[N][N], fa[N][N], sz[N][N];
struct Edge {
  long long next, to;
} edge[N << 1];
inline void add(long long u, long long v) {
  edge[++cnt] = (Edge)<% head[u], v %>;
  head[u] = cnt;
}
void Dfs(long long u, long long fath, long long rt) {
  fa[rt][u] = fath;
  sz[rt][u] = 1;
  for (long long i = head[u]; i; i = edge[i].next) {
    long long v = edge[i].to;
    if (v == fath) continue;
    Dfs(v, u, rt);
    sz[rt][u] += sz[rt][v];
  }
}
long long Solve(long long x, long long y) {
  if (x == y) return 0;
  if (dp[x][y] != -1) return dp[x][y];
  return dp[x][y] =
             max(Solve(fa[y][x], y), Solve(x, fa[x][y])) + sz[x][y] * sz[y][x];
}
signed main() {
  n = read();
  for (long long i = 1, u, v; i < n; ++i) {
    u = read(), v = read();
    add(u, v), add(v, u);
  }
  for (long long i = 1; i <= n; ++i) Dfs(i, 0, i);
  memset(dp, -1, sizeof(dp));
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= n; ++j) ans = max(ans, Solve(i, j));
  printf("%lld\n", ans);
  return 0;
}
