#include <bits/stdc++.h>
using namespace std;
int par[3001][3001];
long long sub[3001][3001];
long long dp[3001][3001];
int n;
vector<int> vertices[3001];
void dfs(int x, int f, int root) {
  par[root][x] = f;
  sub[root][x] = 1;
  for (auto i : vertices[x]) {
    if (i == f) continue;
    dfs(i, x, root);
    sub[root][x] += sub[root][i];
  }
}
long long solve(int u, int v) {
  if (u == v) return 0;
  if (~dp[u][v]) return dp[u][v];
  return dp[u][v] = sub[u][v] * sub[v][u] +
                    max(solve(u, par[u][v]), solve(v, par[v][u]));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    vertices[u].push_back(v);
    vertices[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    dfs(i, i, i);
  }
  long long ans = 0;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      ans = max(ans, solve(i, j));
    }
  printf("%lld", ans);
}
