#include <bits/stdc++.h>
using namespace std;
long long n, root, a[3005][3005], s[3005][3005], v[3005][3005];
vector<long long> e[3005];
void dfs(long long now) {
  s[root][now] = 1;
  for (long long i = 0; i < e[now].size(); i++)
    if (e[now][i] != a[root][now]) {
      a[root][e[now][i]] = now;
      dfs(e[now][i]);
      s[root][now] += s[root][e[now][i]];
    }
}
long long dp(long long x, long long y) {
  if (x == y) return 0;
  if (v[x][y]) return v[x][y];
  v[x][y] = s[x][y] * s[y][x] + max(dp(x, a[x][y]), dp(y, a[y][x]));
  return v[x][y];
}
signed main() {
  scanf("%lld", &n);
  long long x, y, ans = 0;
  for (long long i = 1; i < n; i++) {
    scanf("%lld%lld", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    root = i;
    dfs(root);
  }
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) ans = max(ans, dp(i, j));
  printf("%lld", ans);
  return 0;
}
