#include <bits/stdc++.h>
using namespace std;
int n;
int dist[3005][3005];
int par[3005][3005];
long long dp[3005][3005];
long long sz[3005][3005];
vector<pair<int, int> > v[3005];
vector<int> graph[3005];
void dfs(int n, int s) {
  sz[s][n] = 1;
  for (int e : graph[n]) {
    if (par[s][n] != e) {
      par[s][e] = n;
      dist[s][e] = dist[s][n] + 1;
      v[dist[s][e]].push_back({s, e});
      dfs(e, s);
      sz[s][n] += sz[s][e];
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, i);
  }
  long long ans = 0;
  for (int k = 1; k <= n; k++) {
    for (auto p : v[k]) {
      int n = p.first, m = p.second;
      long long c = sz[n][m] * sz[m][n];
      dp[n][m] = max(dp[n][m], dp[par[m][n]][m] + c);
      dp[n][m] = max(dp[n][m], dp[n][par[n][m]] + c);
      ans = max(dp[n][m], ans);
    }
  }
  cout << ans << endl;
}
