#include <bits/stdc++.h>
const long long MAXN = 3000 + 5;
struct Edge {
  long long to, nxt;
} e[MAXN << 1];
long long head[MAXN], cnt;
inline void add(long long u, long long v) {
  e[++cnt] = (Edge){v, head[u]};
  head[u] = cnt;
  e[++cnt] = (Edge){u, head[v]};
  head[v] = cnt;
}
long long sz[MAXN][MAXN], fa[MAXN][MAXN];
long long rt;
inline void dfs(long long v) {
  sz[rt][v] = 1;
  for (long long i = head[v]; i; i = e[i].nxt) {
    if (e[i].to == fa[rt][v]) continue;
    fa[rt][e[i].to] = v;
    dfs(e[i].to);
    sz[rt][v] += sz[rt][e[i].to];
  }
}
long long f[MAXN][MAXN];
inline long long dp(long long x, long long y) {
  if (x == y) return 0;
  if (f[x][y] != -1) return f[x][y];
  return f[x][y] =
             std::max(dp(fa[y][x], y), dp(x, fa[x][y])) + sz[y][x] * sz[x][y];
}
long long n;
signed main() {
  scanf("%lld", &n);
  for (long long i = 2; i <= n; ++i) {
    long long u, v;
    scanf("%lld%lld", &u, &v);
    add(u, v);
  }
  for (long long i = 1; i <= n; ++i) {
    rt = i;
    dfs(rt);
  }
  memset(f, -1, sizeof(f));
  for (long long v = 1; v <= n; ++v) {
    for (long long i = head[v]; i; i = e[i].nxt) {
      f[e[i].to][v] = f[v][e[i].to] = sz[e[i].to][v] * sz[v][e[i].to];
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= i; ++j) {
      ans = std::max(ans, dp(i, j));
    }
  }
  printf("%lld\n", ans);
  return 0;
}
