#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
vector<int> edge[MAXN];
int n, fa[MAXN][MAXN];
long long ans, cnt[MAXN][MAXN], dp[MAXN][MAXN];
long long solve(int a, int b) {
  if (a == b) return 0;
  if (dp[a][b] != -1) return dp[a][b];
  return dp[a][b] = cnt[a][b] * cnt[b][a] +
                    max(solve(fa[a][b], a), solve(fa[b][a], b));
}
void search(int root, int k, int dad) {
  cnt[root][k]++;
  fa[root][k] = dad;
  for (auto t : edge[k]) {
    if (t != dad) {
      search(root, t, k);
      cnt[root][k] += cnt[root][t];
    }
  }
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) search(i, i, -1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) ans = max(ans, solve(i, j));
  cout << ans;
  return 0;
}
