#include <bits/stdc++.h>
using namespace std;
const int N = 3050;
long long dp[N][N];
int p[N][N], s[N][N];
vector<int> e[N];
void dfs(int rt, int u, int pre) {
  p[rt][u] = pre;
  s[rt][u] = 1;
  for (int v : e[u]) {
    if (v == pre) continue;
    dfs(rt, v, u);
    s[rt][u] += s[rt][v];
  }
}
long long solve(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v]) return dp[u][v];
  return dp[u][v] =
             max(solve(u, p[u][v]), solve(p[v][u], v)) + s[u][v] * s[v][u];
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, i, 0);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      ans = max(ans, solve(i, j));
    }
  printf("%lld\n", ans);
}
