#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
int P[N][N], SZ[N][N];
long long M[N][N];
vector<int> g[N];
int dfs(int v, int r, int p = 0) {
  P[r][v] = p;
  for (int u : g[v])
    if (u != p) SZ[r][v] += dfs(u, r, v);
  return ++SZ[r][v];
}
long long DP(int u, int v) {
  if (u == v || M[u][v]) return M[u][v];
  return M[v][u] = M[u][v] =
             1ll * SZ[v][u] * SZ[u][v] + max(DP(P[v][u], v), DP(u, P[u][v]));
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) dfs(i, i);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans = max(ans, DP(i, j));
  cout << ans << "\n";
}
