#include <bits/stdc++.h>
using namespace std;
int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}
const int N = 3000 + 10;
int n;
struct edge {
  int v, nxt;
} e[N << 1];
int head[N];
void add(int u, int v) {
  static int cnt = 0;
  e[++cnt] = (edge){v, head[u]}, head[u] = cnt;
}
int fa[N][N], sz[N][N];
void dfs(int rt, int u, int f) {
  fa[rt][u] = f, sz[rt][u] = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == f) continue;
    dfs(rt, v, u);
    sz[rt][u] += sz[rt][v];
  }
}
long long dp[N][N];
long long calc(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v]) return dp[u][v];
  return dp[u][v] =
             max(calc(fa[v][u], v), calc(u, fa[u][v])) + sz[u][v] * sz[v][u];
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    int u = read(), v = read();
    add(u, v), add(v, u);
  }
  for (int i = 1; i <= n; ++i) dfs(i, i, 0);
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) ans = max(ans, calc(i, j));
  printf("%lld\n", ans);
  return 0;
}
