#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[3001];
long long dp[3001][3001];
long long subct[3001];
int parent[3001];
void dfs(int node, int par) {
  parent[node] = par;
  subct[node] = 1;
  for (auto it : adj[node]) {
    if (it == par) continue;
    dfs(it, node);
    subct[node] += subct[it];
  }
}
long long solve(int node1, int node2, int par1, int par2) {
  if (dp[node1][node2] != -1) return dp[node1][node2];
  dp[node1][node2] = 0;
  long long val1, val2;
  if (par1 == parent[node1])
    val1 = subct[node1];
  else
    val1 = (n - subct[par1]);
  if (par2 == parent[node2])
    val2 = subct[node2];
  else
    val2 = (n - subct[par2]);
  long long x = val1 * val2;
  for (auto it : adj[node1]) {
    if (it == par1) continue;
    dp[node1][node2] = (dp[node1][node2] > solve(it, node2, node1, par2)
                            ? dp[node1][node2]
                            : solve(it, node2, node1, par2));
  }
  for (auto it : adj[node2]) {
    if (it == par2) continue;
    dp[node1][node2] = (dp[node1][node2] > solve(node1, it, par1, node2)
                            ? dp[node1][node2]
                            : solve(node1, it, par1, node2));
  }
  dp[node1][node2] += x;
  return dp[node1][node2];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 1);
  memset(dp, -1, sizeof(dp));
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (auto it : adj[i])
      ans = (ans > solve(i, it, it, i) ? ans : solve(i, it, it, i));
  cout << ans;
}
