#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e3 + 5;
vector<int> G[N];
int fa[N][N], sz[N][N];
long long dp[N][N], ans;
void dfs(int u, int f, int root) {
  sz[root][u] = 1;
  fa[root][u] = f;
  for (auto v : G[u]) {
    if (v == f) continue;
    dfs(v, u, root);
    sz[root][u] += sz[root][v];
  }
}
long long sl(int x, int y) {
  if (x == y) return 0;
  if (dp[x][y] != -1) return dp[x][y];
  dp[x][y] = 1ll * sz[y][x] * sz[x][y] + max(sl(fa[y][x], y), sl(x, fa[x][y]));
  return dp[x][y];
}
int main() {
  std::ios::sync_with_stdio(0);
  int n;
  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++) {
    dfs(i, 0, i);
  }
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      ans = max(ans, sl(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}
