#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e3 + 9;
const int maxm = (int)1e6 + 9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-15;
vector<int> e[maxn];
long long f[maxn][maxn];
int n;
int fa[maxn][maxn];
int sz[maxn][maxn];
void init() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
}
void dfs(int u, int f, int r) {
  fa[r][u] = f;
  sz[r][u] = 1;
  for (int x : e[u]) {
    if (f == x) continue;
    dfs(x, u, r);
    sz[r][u] += sz[r][x];
  }
}
long long dp(int u, int v) {
  if (u == v) return 0;
  if (f[u][v] >= 0) return f[u][v];
  int fu = fa[v][u];
  int fv = fa[u][v];
  f[u][v] = max(dp(fu, v), dp(u, fv)) + sz[v][u] * sz[u][v];
  f[v][u] = f[u][v];
  return f[u][v];
}
int main() {
  init();
  memset(f, -1, sizeof(f));
  for (int i = 0; i < n; i++) {
    dfs(i, -1, i);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans = max(ans, dp(i, j));
    }
  }
  printf("%lld\n", ans);
  return 0;
}
