#include <bits/stdc++.h>
using namespace std;
vector<int> L[3010];
int fth[3010][3010], s[3010][3010], viz[3010];
long long dp[3010][3010];
int n, m, x, y, i, j;
void pre_dfs(int nod, int tata, int rad) {
  fth[rad][nod] = tata;
  s[rad][nod] = 1;
  for (auto vecin : L[nod]) {
    if (vecin != fth[rad][nod]) {
      pre_dfs(vecin, nod, rad);
      s[rad][nod] += s[rad][vecin];
    }
  }
}
long long dfs(int x, int y) {
  if (x == y) return 0;
  if (dp[x][y] != -1) return dp[x][y];
  long long val =
      1LL * s[x][y] * s[y][x] + max(dfs(fth[y][x], y), dfs(x, fth[x][y]));
  dp[x][y] = val;
  return val;
}
int main() {
  FILE *fin = stdin;
  FILE *fout = stdout;
  fscanf(fin, "%d", &n);
  for (i = 1; i < n; ++i) {
    fscanf(fin, "%d%d", &x, &y);
    L[x].push_back(y);
    L[y].push_back(x);
  }
  for (i = 1; i <= n; ++i) pre_dfs(i, 0, i);
  memset(dp, -1, sizeof dp);
  long long sol = 0;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) {
      sol = max(sol, dfs(i, j));
    }
  fprintf(fout, "%lld", sol);
  return 0;
}
