#include <bits/stdc++.h>
using namespace std;
const int N = 3000;
int n;
struct side {
  int y, next;
} e[N * 2 + 9];
int lin[N + 9], cs;
void Ins(int x, int y) {
  e[++cs].y = y;
  e[cs].next = lin[x];
  lin[x] = cs;
}
void Ins2(int x, int y) {
  Ins(x, y);
  Ins(y, x);
}
void into() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    Ins2(x, y);
  }
}
int fa[N + 9][N + 9], siz[N + 9][N + 9];
void Dfs_siz(int k, int fat, int rot) {
  fa[rot][k] = fat;
  siz[rot][k] = 1;
  for (int i = lin[k]; i; i = e[i].next)
    if (e[i].y ^ fat) {
      Dfs_siz(e[i].y, k, rot);
      siz[rot][k] += siz[rot][e[i].y];
    }
}
void Get_siz() {
  for (int i = 1; i <= n; ++i) Dfs_siz(i, 0, i);
}
long long dp[N + 9][N + 9];
long long Dfs_dp(int x, int y) {
  if (x == y) return 0;
  if (dp[x][y]) return dp[x][y];
  return dp[x][y] = (long long)siz[x][y] * siz[y][x] +
                    max(Dfs_dp(x, fa[x][y]), Dfs_dp(fa[y][x], y));
}
long long ans;
void Get_dp() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) ans = max(ans, Dfs_dp(i, j));
}
void work() {
  Get_siz();
  Get_dp();
}
void outo() { printf("%lld\n", ans); }
int main() {
  into();
  work();
  outo();
  return 0;
}
