#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
int n;
vector<int> way[maxn];
int len[maxn][maxn], sz[maxn][maxn];
vector<pair<int, int>> have[maxn];
long long dp[maxn][maxn];
void root(int u, int last, int x, int cur) {
  len[x][u] = cur;
  sz[x][u] = 1;
  have[cur].push_back({x, u});
  for (auto v : way[u]) {
    if (v == last) continue;
    root(v, u, x, cur + 1);
    sz[x][u] += sz[x][v];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    way[u].push_back(v);
    way[v].push_back(u);
  }
  for (int u = 1; u <= n; u++) root(u, 0, u, 0);
  long long ans = 0;
  for (int d = n - 1; d >= 1; d--) {
    for (auto tmp : have[d]) {
      int u = tmp.first, v = tmp.second, uu, vv;
      long long mx = 0;
      for (auto x : way[u])
        if (len[u][x] + len[x][v] == len[u][v]) uu = x;
      for (auto x : way[v])
        if (len[u][x] + len[x][v] == len[u][v]) vv = x;
      for (auto x : way[u]) {
        if (x == uu) continue;
        mx = max(mx, dp[x][v]);
      }
      for (auto x : way[v]) {
        if (x == vv) continue;
        mx = max(mx, dp[u][x]);
      }
      dp[u][v] = mx + (long long)sz[uu][u] * sz[vv][v];
      ans = max(ans, dp[u][v]);
    }
  }
  printf("%lld", ans);
}
