#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int fa[maxn][maxn];
int size[maxn][maxn];
long long dp[maxn][maxn];
vector<int> v[maxn];
void dfs(int now, int root, int pre) {
  size[root][now] = 1;
  fa[root][now] = pre;
  for (int i = 0; i < v[now].size(); ++i) {
    int to = v[now][i];
    if (to == pre) continue;
    dfs(to, root, now);
    size[root][now] += size[root][to];
  }
}
long long solve(int x, int y) {
  if (x == y || x == 0 || y == 0) return 0;
  if (dp[x][y] != -1) return dp[x][y];
  int ls = size[y][x];
  int rs = size[x][y];
  return dp[x][y] = 1ll * ls * rs + max(solve(fa[y][x], y), solve(x, fa[x][y]));
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) dfs(i, i, 0);
  memset(dp, -1, sizeof(dp));
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) ans = max(ans, solve(i, j));
  }
  cout << ans << endl;
  return 0;
}
