#include <bits/stdc++.h>
using namespace std;
long long int bg = 9982443530987;
vector<vector<long long int> > vec(3000);
vector<vector<pair<long long int, long long int> > > store(3000);
long long int dp[3000][3000], par[3000][3000], size[3000][3000],
    dis[3000][3000];
long long int n;
void dfs(long long int r, long long int i, long long int pari) {
  par[r][i] = pari;
  size[r][i] = 1;
  if (i != r) dis[r][i] = 1 + dis[r][pari];
  for (long long int j = 0; j < vec[i].size(); j++)
    if (vec[i][j] != pari) {
      dfs(r, vec[i][j], i);
      size[r][i] += size[r][vec[i][j]];
    }
}
void boom() {
  long long int i, j;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    long long int a, b;
    cin >> a >> b;
    vec[a - 1].push_back(b - 1);
    vec[b - 1].push_back(a - 1);
  }
  for (i = 0; i < n; i++) dfs(i, i, i);
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++) store[dis[i][j]].push_back(make_pair(i, j));
  long long int ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < store[i].size(); j++) {
      long long int u = store[i][j].first, v = store[i][j].second;
      dp[u][v] = dp[v][u] =
          size[v][u] * size[u][v] + max(dp[v][par[v][u]], dp[u][par[u][v]]);
      ans = max(ans, dp[u][v]);
    }
  }
  cout << ans;
}
int main() {
  long long int t, i, j, n;
  t = 1;
  while (t--) boom();
  cout << '\n';
  return 0;
}
