#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long w = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    w = (w << 3) + (w << 1) + ch - 48;
    ch = getchar();
  }
  return w * f;
}
long long n, m, cnt, head[200010], siz[3010][3010], f[3010][3010],
    dp[3010][3010];
struct Edge {
  long long from, to, next;
} edge[200010];
inline void addedge(long long u, long long v) {
  cnt++;
  edge[cnt].from = u;
  edge[cnt].to = v;
  edge[cnt].next = head[u];
  head[u] = cnt;
}
inline void ins(long long u, long long v) {
  addedge(u, v);
  addedge(v, u);
  return;
}
inline void dfs(long long root, long long u, long long fa) {
  f[root][u] = fa;
  siz[root][u] = 1;
  for (long long i = head[u]; i; i = edge[i].next) {
    long long v = edge[i].to;
    if (v == fa) continue;
    dfs(root, v, u);
    siz[root][u] += siz[root][v];
  }
}
inline long long solve(long long u, long long v) {
  if (u == v) return 0;
  if (dp[u][v] != -1)
    return dp[u][v];
  else
    return dp[u][v] = siz[u][v] * siz[v][u] +
                      max(solve(f[v][u], v), solve(f[u][v], u));
}
signed main() {
  n = read();
  memset(dp, -1, sizeof(dp));
  for (long long i = 1; i < n; i++) {
    long long x = read();
    long long y = read();
    ins(x, y);
  }
  for (long long i = 1; i <= n; i++) {
    dfs(i, i, 0);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}
