#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
using LL = long long;
vector<int> G[MAXN];
int n;
LL cnt[MAXN][MAXN], dp[MAXN][MAXN], fa[MAXN][MAXN];
void dfs(int rt, int u, int f) {
  cnt[rt][u] = 1;
  fa[rt][u] = f;
  for (auto v : G[u]) {
    if (v == f) continue;
    dfs(rt, v, u);
    cnt[rt][u] += cnt[rt][v];
  }
}
LL solve(int x, int y) {
  if (x == y) return 0;
  if (~dp[x][y]) return dp[x][y];
  dp[x][y] =
      cnt[y][x] * cnt[x][y] + max(solve(fa[x][y], x), solve(fa[y][x], y));
  return dp[x][y];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int u, v;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) dfs(i, i, 0);
  memset(dp, -1, sizeof dp);
  LL ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}
