#include <bits/stdc++.h>
using namespace std;
long long n, u[6005], v[6005], first[3005], nxt[6005];
long long f[3005][3005], fa[3005][3005], size[3005][3005], ans;
inline void dfs1(register long long now, register long long f,
                 register long long root) {
  size[root][now] = 1, fa[root][now] = f;
  for (register long long i = first[now]; i; i = nxt[i])
    if (v[i] != f) {
      dfs1(v[i], now, root);
      size[root][now] += size[root][v[i]];
    }
  return;
}
inline long long dfs2(register long long a, register long long b) {
  if (f[a][b] != -1) return f[a][b];
  long long now = size[a][b] * size[b][a];
  for (register long long i = first[a]; i; i = nxt[i])
    if (v[i] != fa[b][a])
      now = max(now, dfs2(v[i], b) + size[a][b] * size[b][a]);
  for (register long long i = first[b]; i; i = nxt[i])
    if (v[i] != fa[a][b])
      now = max(now, dfs2(a, v[i]) + size[a][b] * size[b][a]);
  return f[a][b] = now;
}
signed main() {
  cin >> n;
  for (long long i = 1; i < n; i++) {
    cin >> u[i] >> v[i];
    nxt[i] = first[u[i]], first[u[i]] = i;
    u[i + n] = v[i], v[i + n] = u[i];
    nxt[i + n] = first[u[i + n]], first[u[i + n]] = i + n;
  }
  for (long long i = 1; i <= n; i++) dfs1(i, 0, i);
  memset(f, -1, sizeof(f));
  for (long long i = 1; i < n; i++) ans = max(ans, dfs2(u[i], v[i]));
  cout << ans << endl;
  return 0;
}
