#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5, INF = int(1e9), mod = 1e9 + 7;
const long long BIG = 1e18;
long long n, dp[N][N], sz[N][N], cur, p[N][N], ans;
vector<int> g[N];
void rec(int v, int pr) {
  sz[cur][v] = 1;
  p[cur][v] = pr;
  for (auto e : g[v]) {
    if (e != pr) {
      rec(e, v);
      sz[cur][v] += sz[cur][e];
    }
  }
}
long long go(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  dp[u][v] = max(go(p[v][u], v), go(u, p[u][v])) + sz[u][v] * sz[v][u];
  return dp[u][v];
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof dp);
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    cur = i;
    rec(i, i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) go(i, j);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans;
}
