#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 5;
int n;
vector<int> adj[MAXN];
int siz[MAXN], p[MAXN], way[MAXN][MAXN];
long long ans[MAXN][MAXN];
void genSiz(int pos, int prev) {
  siz[pos] = 1;
  p[pos] = prev;
  for (int i : adj[pos])
    if (prev != i) {
      genSiz(i, pos);
      siz[pos] += siz[i];
    }
}
long long getSub(int pos, int prev) {
  if (p[pos] == prev) return siz[pos];
  return n - siz[prev];
}
void genWay(int axis, int pos, int prev) {
  way[pos][axis] = prev;
  for (int i : adj[pos])
    if (prev != i) {
      genWay(axis, i, pos);
    }
}
long long dp(int l, int r) {
  if (ans[l][r] >= 0) return ans[l][r];
  ans[l][r] = getSub(l, way[l][r]) * getSub(r, way[r][l]);
  long long toAdd = 0LL;
  for (int i : adj[l])
    if (i != way[l][r]) {
      toAdd = max(toAdd, dp(i, r));
    }
  for (int i : adj[r])
    if (i != way[r][l]) {
      toAdd = max(toAdd, dp(l, i));
    }
  ans[l][r] += toAdd;
  return ans[l][r];
}
int main() {
  scanf("%d", &n);
  memset(ans, -1, sizeof ans);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  genSiz(1, -1);
  for (int i = 1; i <= n; ++i) {
    genWay(i, i, -1);
  }
  long long finalAns = 0LL;
  for (int i = 1; i <= n; ++i)
    for (int j : adj[i]) finalAns = max(finalAns, dp(i, j));
  printf("%lld\n", finalAns);
}
