#include <bits/stdc++.h>
using namespace std;
const int maxn = 3123;
int dis[maxn][maxn], n, sz[maxn][maxn], dep[maxn], anc[maxn][12];
bool vis[maxn][maxn];
long long f[maxn][maxn], ans;
vector<int> G[maxn];
void dfs(int u, int par) {
  dep[u] = dep[par] + 1;
  anc[u][0] = par;
  for (int(i) = (1); (i) <= (11); (i)++) anc[u][i] = anc[anc[u][i - 1]][i - 1];
  for (auto v : G[u])
    if (v != par) dfs(v, u);
}
void dfs3(int u, int par) {
  sz[u][par] = 1;
  for (auto v : G[u])
    if (v != par) {
      dfs3(v, u);
      sz[u][par] += sz[v][u];
    }
}
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int(i) = (11); (i) >= (0); (i)--)
    if (dep[anc[v][i]] >= dep[u]) v = anc[v][i];
  if (v == u) return u;
  for (int(i) = (11); (i) >= (0); (i)--)
    if (anc[u][i] != anc[v][i]) u = anc[u][i], v = anc[v][i];
  return anc[u][0];
}
long long solve(int u, int pu, int v, int pv) {
  if (u > v) swap(u, v), swap(pu, pv);
  if (vis[u][v]) return f[u][v];
  long long &ret = f[u][v];
  vis[u][v] = true;
  ret = 0;
  for (auto nu : G[u])
    if (nu != pu) ret = max(ret, solve(nu, u, v, pv));
  for (auto nv : G[v])
    if (nv != pv) ret = max(ret, solve(u, pu, nv, v));
  return ret += sz[u][pu] * sz[v][pv];
}
void dfs2(int u, int par) {
  for (auto v : G[u])
    if (v != par) {
      ans = max(ans, solve(u, v, v, u));
      dfs2(v, u);
    }
}
int main() {
  scanf("%d", &n);
  for (int(i) = (0); (i) <= ((n - 1) - 1); (i)++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  dfs(1, 0);
  for (int(i) = (1); (i) <= (n); (i)++) dfs3(i, 0);
  for (int(i) = (1); (i) <= (n); (i)++)
    for (int(j) = (i + 1); (j) <= (n); (j)++)
      dis[i][j] = dep[i] + dep[j] - 2 * dep[lca(i, j)];
  dfs2(1, 0);
  printf("%lld", ans);
}
