#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
vector<int> G[N];
int sz[N][N], par[N][N];
long long dp[N][N];
int n, u, v;
void dfs(int u, int p, int rt) {
  sz[rt][u] = 1, par[rt][u] = p;
  for (auto v : G[u])
    if (v != p) {
      dfs(v, u, rt);
      sz[rt][u] += sz[rt][v];
    }
}
long long calc(int u, int v) {
  if (dp[u][v] != -1) return dp[u][v];
  dp[u][v] = dp[v][u] =
      max(calc(u, par[u][v]), calc(par[v][u], v)) + sz[u][v] * sz[v][u];
  return dp[u][v];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) dfs(i, 0, i);
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) dp[i][i] = 0;
  long long res = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (dp[i][j] == -1) res = max(res, dp[i][j] = calc(i, j));
  cout << res << endl;
  return 0;
}
