#include <bits/stdc++.h>
using namespace std;
const int inf = 1e18;
const int N = 3e3 + 222;
long long dp[N][N];
int sz[N][N];
int len[N][N];
int p[N][N];
vector<int> g[N];
void calc(int v, int pr, int r) {
  sz[r][v] = 1;
  p[r][v] = pr;
  for (auto to : g[v]) {
    if (to == pr) continue;
    len[r][to] = len[r][v] + 1;
    calc(to, v, r);
    sz[r][v] += sz[r][to];
  }
}
void dfs(int v, int r) {
  dp[r][v] = sz[r][v] * sz[v][r] + max(max(dp[r][p[r][v]], dp[v][p[v][r]]),
                                       max(dp[p[r][v]][r], dp[p[v][r]][v]));
  dp[v][r] = dp[r][v];
}
int main() {
  ios_base::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;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; ++i) {
    calc(i, i, i);
  }
  vector<pair<int, pair<int, int>>> v;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      v.push_back({len[i][j], {i, j}});
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < (long long)v.size(); ++i) {
    dfs(v[i].second.second, v[i].second.first);
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
}
