#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
vector<vector<long long>> adj(3100);
long long root;
long long sub[3100][3100];
long long par[3100][3100];
long long dp[3100][3100];
long long ans = 0;
void dfs(long long n, long long p) {
  sub[root][n] = 1;
  for (auto it : adj[n]) {
    if (it == p) {
      continue;
    }
    par[root][it] = n;
    dfs(it, n);
    sub[root][n] += sub[root][it];
  }
}
long long solve(long long u, long long v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  long long a = sub[u][v] * sub[v][u] + solve(par[v][u], v);
  long long b = sub[u][v] * sub[v][u] + solve(u, par[u][v]);
  return dp[u][v] = max(a, b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (long long i = 1; i <= n; i++) {
    root = i;
    dfs(i, 0);
  }
  memset(dp, -1, sizeof(dp));
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans;
  return 0;
}
