#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int> > g;
vector<vector<int> > sub, par;
vector<vector<long long> > dp;
void ReadInput() {
  cin >> n;
  g.resize(n + 1);
  sub.resize(n + 1, vector<int>(n + 1));
  par.resize(n + 1, vector<int>(n + 1));
  dp.resize(n + 1, vector<long long>(n + 1, -1));
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
}
int root;
void dfs(int u, int p) {
  par[root][u] = p;
  sub[root][u] = 1;
  for (int v : g[u])
    if (v != p) {
      dfs(v, u);
      sub[root][u] += sub[root][v];
    }
}
long long DP(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  long long res =
      sub[u][v] * 1LL * sub[v][u] + max(DP(par[v][u], v), DP(u, par[u][v]));
  return dp[u][v] = res;
}
void Solve() {
  for (int i = 1; i <= n; ++i) {
    root = i;
    dfs(i, 0);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) ans = max(ans, DP(i, j));
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ReadInput();
  Solve();
}
