#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 998244353;
const int INF = 1e9 + 7;
int n, par[3005][3005], sz[3005][3005];
long long dp[3005][3005];
struct edge {
  int v, nxt;
} e[6010];
int head[3005], tot = 1;
void addedge(int u, int v) {
  e[tot] = (edge){v, head[u]};
  head[u] = tot++;
  e[tot] = (edge){u, head[v]};
  head[v] = tot++;
}
void dfs(int r, int u, int fa) {
  sz[r][u] = 1;
  par[r][u] = fa;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(r, v, u);
    sz[r][u] += sz[r][v];
  }
}
long long DP(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  long long res = sz[u][v] * sz[v][u] + max(DP(par[v][u], v), DP(u, par[u][v]));
  dp[u][v] = res;
  return res;
}
void solve() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d %d", &u, &v);
    addedge(u, v);
  }
  for (int i = 1; i <= n; i++) dfs(i, i, 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, DP(i, j));
    }
  }
  printf("%lld\n", ans);
}
int main() {
  solve();
  return 0;
}
