#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
int root;
long long dp[maxn][maxn];
int p[maxn][maxn], sz[maxn][maxn];
vector<int> G[maxn];
int n;
void dfs1(int u, int par) {
  sz[root][u] = 1;
  p[root][u] = par;
  for (int v : G[u])
    if (v != par) {
      dfs1(v, u);
      sz[root][u] += sz[root][v];
    }
}
long long dfs(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  long long res = sz[u][v] * sz[v][u] + max(dfs(p[u][v], u), dfs(p[v][u], v));
  return dp[u][v] = res;
}
int main(int argc, const char *argv[]) {
  memset(sz, 0, sizeof(sz));
  memset(p, 0, sizeof(p));
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    root = i;
    dfs1(root, -1);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) ans = max(ans, dfs(i, j));
  cout << ans << endl;
  return 0;
}
