#include <bits/stdc++.h>
using namespace std;
const int N = 3007;
int n;
vector<int> adj[N];
int child[N][N], par[N][N];
long long res;
long long f[N][N];
void dfs_prepare(int u, int root) {
  child[root][u] = 1;
  for (int v : adj[u]) {
    if (!child[root][v]) {
      dfs_prepare(v, root);
      par[root][v] = u;
      child[root][u] += child[root][v];
    }
  }
}
long long dp(int u, int v) {
  if (u == v) return 0;
  if (f[u][v] != 0) return f[u][v];
  long long res =
      max(dp(u, par[u][v]), dp(par[v][u], v)) + 1LL * child[u][v] * child[v][u];
  return f[u][v] = res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  if (fopen("test.inp", "r"))
    freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) dfs_prepare(i, i);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) res = max(res, dp(i, j));
  cout << res;
}
