#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
int n;
vector<int> G[maxn];
int fa[3010][3010], siz[3010][3010];
void dfs1(int u, int _fa, int rt) {
  fa[rt][u] = _fa;
  siz[rt][u] = 1;
  for (int v : G[u]) {
    if (v == _fa) continue;
    dfs1(v, u, rt);
    siz[rt][u] += siz[rt][v];
  }
}
long long dp[3010][3010];
long long dfs2(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  return dp[u][v] = 1ll * siz[v][u] * siz[u][v] +
                    1ll * max(dfs2(u, fa[u][v]), dfs2(v, fa[v][u]));
}
long long ans;
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    dfs1(i, 0, i);
  }
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      ans = max(dfs2(i, j), ans);
    }
  }
  cout << ans << endl;
  return 0;
}
