#include <bits/stdc++.h>
using namespace std;
const int mod = int(1e9 + 7), MAXN = int(3e3 + 50);
long long n, d[MAXN][MAXN], o[MAXN][MAXN], dp[MAXN][MAXN];
vector<int> v[MAXN];
void dfs(int i, int ot, int k) {
  o[k][i] = ot;
  d[k][i] = 1;
  for (auto j : v[i])
    if (j != ot) {
      dfs(j, i, k);
      d[k][i] += d[k][j];
    }
}
long long getdp(int i, int j) {
  if (i == j) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  dp[i][j] = d[j][i] * d[i][j] + max(getdp(o[j][i], j), getdp(i, o[i][j]));
  return dp[i][j];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int p, q;
    cin >> p >> q;
    v[p].push_back(q);
    v[q].push_back(p);
  }
  for (int i = 1; i <= n; i++) dfs(i, -1, i);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dp[i][j] = -1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) ans = max(ans, getdp(i, j));
  printf("%lld\n", ans);
  return 0;
}
