#include <bits/stdc++.h>
using namespace std;
long long int sub[3005][3005];
int par[3005][3005];
long long int dp[3005][3005];
long long int gdp(long long int i, long long int j) {
  if (i == j) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  dp[i][j] = sub[i][j] * sub[j][i] + max(gdp(par[i][j], i), gdp(par[j][i], j));
  return dp[i][j];
}
void dfs(long long int a, list<long long int> *adj, long long int p,
         long long int g_p) {
  sub[g_p][a] = 1;
  for (auto u : adj[a]) {
    if (u != p) {
      dfs(u, adj, a, g_p);
      sub[g_p][a] += sub[g_p][u];
      par[g_p][u] = a;
    }
  }
}
int main() {
  long long int n;
  cin >> n;
  list<long long int> adj[n + 1];
  memset(dp, -1, sizeof(dp));
  for (long long int i = 0; i < n - 1; i++) {
    long long int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (long long int i = 1; i <= n; i++) dfs(i, adj, -1, i);
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      ans = max(ans, gdp(i, j));
    }
  }
  cout << ans << endl;
}
