#include <bits/stdc++.h>
using namespace std;
vector<int> adj[3005];
int par[3005][3005], sub[3005][3005];
long long dp[3005][3005];
void dfs(int r, int u, int p) {
  sub[r][u] = 1;
  for (auto v : adj[u])
    if (v != p) dfs(r, v, u), sub[r][u] += sub[r][v];
  par[r][u] = p;
}
long long f(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  return dp[u][v] =
             sub[u][v] * sub[v][u] + max(f(par[v][u], v), f(u, par[u][v]));
}
int main() {
  int n, u, v;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    adj[--u].push_back(--v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; i++) dfs(i, i, -1);
  memset(dp, -1, sizeof dp);
  long long res = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) res = max(res, f(i, j));
  cout << res << endl;
  return 0;
}
