#include <bits/stdc++.h>
bool QQQQ;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
using namespace std;
long long ttt = 1;
long long n, a, b;
long long dp[3256][3256], sz[3256][3256], ans;
vector<long long> g[3256];
long long gett(long long v, long long p) {
  long long& cnt = sz[v][p];
  if (cnt) return cnt;
  cnt = 1;
  for (int to : g[v])
    if (to != p) cnt += gett(to, v);
  return cnt;
}
long long calc(long long u, long long pu, long long v, long long pv) {
  if (u > v) {
    swap(u, v);
    swap(pu, pv);
  }
  long long& cnt = dp[u][v];
  if (cnt + 1) return cnt;
  cnt = 0;
  for (int to : g[u])
    if (to != pu)
      cnt = max(cnt, calc(to, u, v, pv) + gett(to, u) * gett(v, pv));
  for (int to : g[v])
    if (to != pv)
      cnt = max(cnt, calc(u, pu, to, v) + gett(to, v) * gett(u, pu));
  return cnt;
}
void solve() {
  scanf("%I64d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%I64d%I64d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= n; i++)
    for (int j : g[i])
      ans = max(ans, calc(i, j, j, i) + gett(i, j) * gett(j, i));
  printf("%I64d", ans);
}
int main() {
  QQQQ = 0;
  for (int i = 1; i <= ttt; i++) solve();
  if (QQQQ) printf("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  ;
}
