#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10, mod = 1e9 + 7;
vector<pair<int, pair<int, int> > > vec;
vector<int> g[N];
int par[N][N], ch[N][N];
long long dp[N][N];
void dfs(int v, int p, int st, int d) {
  ch[st][v] = 1;
  par[st][v] = p;
  if (d != 0 && st < v) vec.push_back({d, {st, v}});
  for (int u : g[v])
    if (u != p) {
      dfs(u, v, st, d + 1);
      ch[st][v] += ch[st][u];
    }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; i++) dfs(i, i, i, 0);
  sort(vec.begin(), vec.end());
  long long ans = 0;
  for (auto x : vec) {
    int d = x.first;
    int u = x.second.first, v = x.second.second;
    if (d == 1) {
      dp[u][v] = dp[v][u] = 1ll * ch[u][v] * ch[v][u];
      ans = max(ans, dp[u][v]);
      continue;
    }
    dp[u][v] = max(dp[u][par[u][v]] + 1ll * ch[u][v] * ch[v][u],
                   dp[v][par[v][u]] + 1ll * ch[v][u] * ch[u][v]);
    dp[v][u] = dp[u][v];
    ans = max(ans, dp[u][v]);
  }
  cout << ans;
  return 0;
}
