#include <bits/stdc++.h>
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0, ff = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -ff;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * ff;
}
void write(long long aa) {
  if (aa < 0) putchar('-'), aa = -aa;
  if (aa > 9) write(aa / 10);
  putchar(aa % 10 + '0');
  return;
}
long long n, ans;
long long sz[3005][3005], f[3005][3005], F[3005][3005];
long long tot, head[3005], nx[6005], to[6005];
struct node {
  long long x, y;
};
queue<node> q;
void jia(long long aa, long long bb) {
  tot++;
  nx[tot] = head[aa];
  to[tot] = bb;
  head[aa] = tot;
  return;
}
void init(long long rt, long long fa, long long zx) {
  sz[zx][rt] = 1;
  F[zx][rt] = fa;
  for (long long i = head[rt]; i; i = nx[i]) {
    long long yy = to[i];
    if (yy == fa) continue;
    init(yy, rt, zx);
    sz[zx][rt] += sz[zx][yy];
  }
  return;
}
int main() {
  n = read();
  for (long long i = 1; i < n; ++i) {
    long long x = read(), y = read();
    jia(x, y);
    jia(y, x);
  }
  for (long long i = 1; i <= n; ++i) init(i, i, i);
  for (long long i = 1; i <= n; ++i) f[i][i] = 0, q.push((node){i, i});
  while (!q.empty()) {
    node kk = q.front();
    q.pop();
    for (long long i = head[kk.x]; i; i = nx[i]) {
      long long yy = to[i];
      if (kk.x != F[kk.y][yy]) continue;
      if (!f[yy][kk.y]) q.push((node){yy, kk.y});
      f[yy][kk.y] =
          max(f[yy][kk.y], f[kk.x][kk.y] + sz[kk.y][yy] * sz[yy][kk.y]);
    }
    for (long long i = head[kk.y]; i; i = nx[i]) {
      long long yy = to[i];
      if (kk.y != F[kk.x][yy]) continue;
      if (!f[kk.x][yy]) q.push((node){kk.x, yy});
      f[kk.x][yy] =
          max(f[kk.x][yy], f[kk.x][kk.y] + sz[kk.x][yy] * sz[yy][kk.x]);
    }
    ans = max(ans, f[kk.x][kk.y]);
  }
  write(ans);
  return 0;
}
