#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e3 + 10;
long long head[maxn];
long long sz[maxn][maxn];
long long f[maxn][maxn];
long long dp[maxn][maxn];
struct Edge {
  long long v, next;
} e[maxn << 1];
long long cnt = 0;
void add(long long u, long long v) {
  e[cnt].v = v;
  e[cnt].next = head[u];
  head[u] = cnt++;
}
void dfs(long long u, long long fa, long long root) {
  sz[root][u] = 1;
  f[root][u] = fa;
  for (long long i = head[u]; ~i; i = e[i].next) {
    long long v = e[i].v;
    if (v == fa) continue;
    dfs(v, u, root);
    sz[root][u] += sz[root][v];
  }
}
long long solve(long long i, long long j) {
  if (dp[i][j] != -1) return dp[i][j];
  if (i == j) return dp[i][j] = 0;
  return dp[i][j] =
             sz[i][j] * sz[j][i] + max(solve(f[i][j], i), solve(f[j][i], j));
}
int main() {
  memset(head, -1, sizeof(head));
  memset(dp, -1, sizeof(dp));
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++) {
    long long u, v;
    scanf("%lld%lld", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (long long i = 1; i <= n; i++) {
    dfs(i, -1, i);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans << endl;
}
