#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int MAXN = 3e3 + 50;
const int MOD = 998244353;
long long qpow(long long a, long long b) {
  long long ret = 1;
  a %= MOD;
  b %= MOD - 1;
  while (b) {
    if (b & 1) ret = a * ret % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
inline long long read() {
  long long tmp = 0, fh = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar();
  return tmp * fh;
}
vector<int> ve[MAXN];
int ln, rn, valn;
int siz[MAXN][MAXN];
int n;
long long dp[MAXN][MAXN];
int par[MAXN][MAXN];
long long dfsdp(long long x, long long y) {
  if (x > y) swap(x, y);
  if (dp[x][y] != -1) return dp[x][y];
  dp[x][y] = 0;
  if (x == y) return 0;
  dp[x][y] = max(dfsdp(par[y][x], y) + siz[x][y] * siz[y][x],
                 dfsdp(x, par[x][y]) + siz[x][y] * siz[y][x]);
  return dp[x][y];
}
void dfs0(int root, int u, int fa) {
  par[root][u] = fa;
  siz[root][u] = 1;
  for (int i = 0; i < ve[u].size(); i++) {
    int v = ve[u][i];
    if (v == fa) continue;
    dfs0(root, v, u);
    siz[root][u] += siz[root][v];
  }
}
void work() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    ve[u].push_back(v);
    ve[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    dfs0(i, i, -1);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      ans = max(ans, dfsdp(i, j));
    }
  }
  printf("%lld\n", ans);
}
int main() { work(); }
