#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 10;
int n, u, v;
long long dp[maxn][maxn];
int siz[maxn][maxn], fa[maxn][maxn], lca[maxn][maxn];
struct Edge {
  int to, nex;
} edge[maxn << 1];
int head[maxn], ecnt;
void add_edge(int u, int v) {
  edge[++ecnt] = {v, head[u]};
  head[u] = ecnt;
}
void calc_size(int root, int now, int father) {
  siz[root][now] = 1;
  for (int i = head[now]; i; i = edge[i].nex) {
    int to = edge[i].to;
    if (to == father) continue;
    calc_size(root, to, now);
    siz[root][now] += siz[root][to];
    fa[root][to] = now;
  }
}
long long go(int u, int v) {
  if (u > v) swap(u, v);
  if (u == v || dp[u][v]) return dp[u][v];
  dp[u][v] =
      1LL * siz[u][v] * siz[v][u] + max(go(fa[v][u], v), go(fa[u][v], u));
  return dp[u][v];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
  }
  for (int i = 1; i <= n; i++) calc_size(i, i, 0);
  long long ans = 0LL;
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) ans = max(ans, go(i, j));
  printf("%lld\n", ans);
  return 0;
}
