#include <bits/stdc++.h>
using namespace std;
const int NMAX = 3000;
int N;
vector<int> g[NMAX + 2];
int root;
int par[NMAX + 2][NMAX + 2];
int subtree[NMAX + 2][NMAX + 2];
long long dp[NMAX + 2][NMAX + 2];
void dfs(int node, int dady) {
  par[root][node] = dady;
  subtree[root][node] = 1;
  for (auto it : g[node])
    if (it != dady) {
      dfs(it, node);
      subtree[root][node] += subtree[root][it];
    }
}
long long GetDp(int p, int q) {
  if (p == 0 || q == 0 || p == q) return 0;
  if (dp[p][q] != -1) return dp[p][q];
  long long res = 1LL * subtree[q][p] * subtree[p][q] +
                  max(GetDp(par[q][p], q), GetDp(p, par[p][q]));
  return dp[p][q] = res;
}
int main() {
  cin >> N;
  for (int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= N; i++) {
    root = i;
    dfs(i, 0);
  }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) dp[i][j] = -1;
  long long ans = 0;
  for (int i = 1; i < N; i++)
    for (int j = i + 1; j <= N; j++) ans = max(ans, GetDp(i, j));
  cout << ans << '\n';
  return 0;
}
