#include <bits/stdc++.h>
using namespace std;
long long ec = 0, hed[3005] = {0}, to[6005], nxt[6005];
void add_edge(long long f, long long t) {
  ++ec;
  to[ec] = t;
  nxt[ec] = hed[f];
  hed[f] = ec;
}
long long fa[3005][3005] = {0}, siz[3005][3005] = {0};
long long dp[3005][3005];
void dfs(long long u, long long f, long long rt) {
  fa[rt][u] = f;
  siz[rt][u] = 1;
  for (long long i = hed[u]; i; i = nxt[i]) {
    long long v = to[i];
    if (v == f) continue;
    dfs(v, u, rt);
    siz[rt][u] += siz[rt][v];
  }
}
long long get_dp(long long u, long long v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  dp[u][v] =
      max(get_dp(fa[v][u], v), get_dp(u, fa[u][v])) + siz[u][v] * siz[v][u];
  return dp[u][v];
}
long long n;
int main() {
  ios::sync_with_stdio(false);
  long long u, v, ans = 0;
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (long long i = 1; i < n; i++) {
    cin >> u >> v;
    add_edge(u, v);
    add_edge(v, u);
  }
  for (long long i = 1; i <= n; i++) dfs(i, 0, i);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      ans = max(ans, get_dp(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}
