#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long LLINF = 1e18 + 7;
int n;
vector<vector<int>> G;
long long par[3009][3009], sub[3009][3009], dp[3009][3009];
int visited[3009];
vector<pair<int, pair<int, int>>> sequence;
void dfs(int v, int root, int d) {
  visited[v] = 1;
  sub[v][root] = 1;
  if (v != root) sequence.push_back({d, {v, root}});
  for (int idx : G[v]) {
    if (!visited[idx]) {
      dfs(idx, root, d + 1);
      par[idx][root] = v;
      sub[v][root] += sub[idx][root];
    }
  }
}
void prep() {
  for (int v = 1; v <= n; v++) {
    for (int i = 1; i <= n; i++) {
      visited[i] = 0;
    }
    dfs(v, v, 0);
  }
}
void dodp() {
  sort((sequence).begin(), (sequence).end());
  for (auto el : sequence) {
    int i = el.second.first, j = el.second.second;
    if (par[i][j] == j) {
      dp[i][j] = sub[i][j] * sub[j][i];
    } else {
      dp[i][j] =
          sub[i][j] * sub[j][i] + max(dp[par[i][j]][j], dp[i][par[j][i]]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  cin >> n;
  G.resize(n + 3);
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  prep();
  dodp();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans;
}
