#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int tot;
long long f[N][N];
int fir[N], size[N][N], fa[N][N];
struct edge {
  int to;
  int nxt;
} e[2 * N];
inline void add(int x, int y) {
  e[++tot].to = y;
  e[tot].nxt = fir[x];
  fir[x] = tot;
  e[++tot].to = x;
  e[tot].nxt = fir[y];
  fir[y] = tot;
}
inline void dfs(int rt, int p) {
  size[rt][p] = 1;
  for (int i = fir[p]; i; i = e[i].nxt) {
    int q = e[i].to;
    if (q == fa[rt][p]) continue;
    fa[rt][q] = p;
    dfs(rt, q), size[rt][p] += size[rt][q];
  }
}
inline long long cal(int p, int q) {
  if (p == q) return 0;
  if (f[p][q]) return f[p][q];
  return f[p][q] =
             max(cal(fa[q][p], q), cal(p, fa[p][q])) + size[q][p] * size[p][q];
}
int main() {
  int n, a, b;
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    add(a, b);
  }
  for (int i = 1; i <= n; i++) dfs(i, i);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans = max(ans, cal(i, j));
  printf("%lld\n", ans);
  return 0;
}
