#include <bits/stdc++.h>
using namespace std;
char *fs, *ft, buf[1 << 15];
inline char getc() {
  return (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft))
             ? 0
             : *fs++;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 3010;
int n, len;
int f[MAXN][MAXN], cnt[MAXN][MAXN];
long long g[MAXN][MAXN], ans;
int lin[MAXN], ver[MAXN << 1], nex[MAXN << 1];
inline void add(int x, int y) {
  ver[++len] = y;
  nex[len] = lin[x];
  lin[x] = len;
}
inline void dfs(int x, int father, int w) {
  cnt[w][x] = 1;
  for (int i = lin[x]; i; i = nex[i]) {
    int tn = ver[i];
    if (tn == father) continue;
    f[w][tn] = x;
    dfs(tn, x, w);
    cnt[w][x] += cnt[w][tn];
  }
}
inline long long dp(int x, int y) {
  if (g[x][y] != -1) return g[x][y];
  if (x == y) return g[x][y] = 0;
  return g[x][y] = cnt[y][x] * cnt[x][y] + max(dp(f[y][x], y), dp(x, f[x][y]));
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    int x, y;
    x = read();
    y = read();
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; ++i) dfs(i, 0, i);
  memset(g, -1, sizeof(g));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) ans = max(ans, dp(i, j));
  }
  printf("%lld\n", ans);
  return 0;
}
