#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
int tot, n;
int ins[maxn][maxn];
long long f[maxn][maxn];
int siz[maxn][maxn], fa[maxn][maxn];
int ver[maxn * 2], Next[maxn * 2], head[maxn];
queue<pair<int, int> > q;
void Add(int x, int y) {
  ver[++tot] = y;
  Next[tot] = head[x];
  head[x] = tot;
}
void dfs(int u, int ff, int rt) {
  siz[rt][u] = 1;
  fa[rt][u] = ff;
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == ff) continue;
    dfs(v, u, rt);
    siz[rt][u] += siz[rt][v];
    if (rt == 1) {
      q.push(make_pair(u, v));
      ins[u][v] = ins[v][u] = 1;
      f[u][v] = f[v][u] = max(f[u][v], (long long)(n - siz[1][v]) * siz[1][v]);
    }
  }
}
int main() {
  int x, y;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    Add(x, y);
    Add(y, x);
  }
  for (int i = 1; i <= n; i++) dfs(i, 0, i);
  long long ans = 0;
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    x = p.first;
    y = p.second;
    ans = max(ans, f[x][y]);
    ins[x][y] = ins[y][x] = 0;
    for (int i = head[x]; i; i = Next[i]) {
      int v = ver[i];
      if (v == fa[y][x]) continue;
      f[v][y] = f[y][v] = max(f[v][y], f[x][y] + siz[x][y] * siz[x][v]);
      if (!ins[v][y]) {
        q.push(make_pair(v, y));
        ins[v][y] = ins[y][v] = 1;
      }
    }
    for (int i = head[y]; i; i = Next[i]) {
      int v = ver[i];
      if (v == fa[x][y]) continue;
      f[x][v] = f[v][x] = max(f[x][v], f[x][y] + siz[y][x] * siz[y][v]);
      if (!ins[x][v]) {
        q.push(make_pair(x, v));
        ins[x][v] = ins[v][x] = 1;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
