#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e16;
long long int ans = 0;
vector<int> v[3333];
long long int sz[3333], dp[3333][3333];
long long int getsz(int now, int left) {
  sz[now] = 1;
  for (int e = 0; e < v[now].size(); e++) {
    int next = v[now][e];
    if (next != left) {
      sz[now] += getsz(next, now);
    }
  }
  return sz[now];
}
long long int recur(int rf, int rs, int f, int s, int pf, int ps) {
  if (dp[f][s] != -1) return dp[f][s];
  dp[f][s] = sz[f] * sz[s];
  for (int e = 0; e < v[f].size(); e++) {
    int next = v[f][e];
    if (next != pf) {
      dp[f][s] = max(dp[f][s], sz[f] * sz[s] + recur(rf, rs, next, s, f, ps));
      dp[s][f] = dp[f][s];
    }
  }
  for (int e = 0; e < v[s].size(); e++) {
    int next = v[s][e];
    if (next != ps) {
      dp[f][s] = max(dp[f][s], sz[f] * sz[s] + recur(rf, rs, f, next, pf, s));
      dp[s][f] = dp[f][s];
    }
  }
  return dp[f][s];
}
int main(void) {
  memset(dp, -1, sizeof(dp));
  int n;
  scanf("%d", &n);
  for (int e = 0; e < n - 1; e++) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int e = 1; e <= n; e++) {
    for (int p = 0; p < v[e].size(); p++) {
      int next = v[e][p];
      memset(sz, 0, sizeof(sz));
      getsz(e, next);
      getsz(next, e);
      ans = max(ans, recur(e, next, e, next, next, e));
    }
  }
  printf("%lld", ans);
  return 0;
}
