#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 3e3 + 5;
const ll LINF = 1e18 + 5;
int n;
vector<int> G[N];
int sz[N][N], f[N][N];
ll dp[N][N], maxn;
void dfs(int u, int fa, int rt) {
  sz[rt][u] = 1;
  f[rt][u] = fa;
  for (int v : G[u]) {
    if (v == fa) continue;
    dfs(v, u, rt);
    sz[rt][u] += sz[rt][v];
  }
}
ll solve(int u, int v) {
  if (~dp[u][v]) return dp[u][v];
  if (u == v) return dp[u][v] = 0;
  return dp[u][v] = max(solve(f[v][u], v), solve(u, f[u][v])) +
                    1ll * sz[u][v] * sz[v][u];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    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++)
    for (int j = 1; j <= n; j++) maxn = max(maxn, solve(i, j));
  cout << maxn;
  return 0;
}
