#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int n, x, y;
int root;
vector<int> v[N];
int fa[N][N];
long long siz[N][N];
long long dp[N][N];
void dfs(int n) {
  siz[root][n] = 1;
  for (auto x : v[n]) {
    if (x == fa[root][n]) continue;
    fa[root][x] = n;
    dfs(x);
    siz[root][n] += siz[root][x];
  }
}
long long cal(long long x, long long y) {
  if (x == y) return 0;
  if (dp[x][y]) return dp[x][y];
  return dp[x][y] =
             siz[y][x] * siz[x][y] + max(cal(fa[y][x], y), cal(x, fa[x][y]));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    root = i;
    dfs(i);
  }
  long long ma = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      long long val = cal(i, j);
      ma = max(ma, val);
    }
  }
  printf("%lld\n", ma);
}
