#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
int n, rt, fa[MAXN][MAXN], son[MAXN][MAXN];
long long f[MAXN][MAXN], ans;
vector<int> G[MAXN];
void build(int u) {
  son[rt][u] = 1;
  for (auto &v : G[u])
    if (v ^ fa[rt][u]) {
      fa[rt][v] = u;
      build(v);
      son[rt][u] += son[rt][v];
    }
}
long long dp(int u, int v) {
  if (u == v) return 0;
  if (f[u][v]) return f[u][v];
  return f[u][v] =
             max(dp(u, fa[u][v]), dp(v, fa[v][u])) + son[u][v] * son[v][u];
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1, u, v; i < n; ++i) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    rt = i;
    build(i);
  }
  for (int u = 1; u <= n; ++u)
    for (int v = 1; v <= n; ++v) ans = max(ans, dp(u, v));
  cout << ans << endl;
  return 0;
}
