#include <bits/stdc++.h>
using namespace std;
long long int par[4000];
long long int sub[4000];
long long int n;
vector<long long int> adj[4000];
long long int dp[4000][4000];
long long int conec[4000][4000];
void dfsc(long long int node, long long int cur, long long int dir,
          long long int prev) {
  conec[node][cur] = dir;
  long long int ele = adj[cur].size();
  for (long long int i = 0; i <= ele - 1; i++) {
    if (adj[cur][i] != prev) {
      dfsc(node, adj[cur][i], dir, cur);
    }
  }
}
void dfss(long long int node) {
  sub[node] = 1;
  long long int ele = adj[node].size();
  for (long long int i = 0; i <= ele - 1; i++) {
    if (par[node] != adj[node][i]) {
      par[adj[node][i]] = node;
      dfss(adj[node][i]);
      sub[node] += sub[adj[node][i]];
    }
  }
}
long long int depth(long long int now, long long int pr) {
  if (adj[now].size() == 1) return 0;
  long long int ret = 0;
  for (long long int i = 0; i <= adj[now].size() - 1; i++) {
    if (adj[now][i] != pr) ret = max(ret, depth(adj[now][i], now));
  }
  return 1 + ret;
}
void dfs(long long int start, long long int fin) {
  if (dp[start][fin] != -1) return;
  if (par[start] == fin) {
    dp[start][fin] = sub[start] * (n - sub[start]);
    return;
  }
  if (par[fin] == start) {
    dp[start][fin] = sub[fin] * (n - sub[fin]);
    return;
  }
  dfs(conec[start][fin], fin);
  dfs(start, conec[fin][start]);
  long long int lef, rig;
  if (par[start] == conec[start][fin])
    lef = sub[start];
  else
    lef = n - sub[conec[start][fin]];
  if (par[fin] == conec[fin][start])
    rig = sub[fin];
  else
    rig = n - sub[conec[fin][start]];
  dp[start][fin] =
      lef * rig + max(dp[start][conec[fin][start]], dp[conec[start][fin]][fin]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int cur, TESTS, q, a, m, s, b, r, c, k, p, w, d, x, i, j, y, z, xs,
      ys, t;
  TESTS = 1;
  memset(par, -1, sizeof(par));
  memset(dp, -1, sizeof(dp));
  while (TESTS--) {
    cin >> n;
    for (long long int i = 0; i <= n - 2; i++) {
      cin >> a >> b;
      a--;
      b--;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    dfss(0);
    for (long long int i = 0; i <= n - 1; i++) {
      long long int ele = adj[i].size();
      for (long long int j = 0; j <= ele - 1; j++) {
        dfsc(i, adj[i][j], adj[i][j], i);
      }
    }
    for (long long int i = 0; i <= n - 1; i++) {
      for (long long int j = 0; j <= n - 1; j++) {
        if (i == j) continue;
        dfs(i, j);
      }
    }
    long long int ans = 0;
    for (long long int i = 0; i <= n - 1; i++)
      for (long long int j = 0; j <= n - 1; j++) ans = max(ans, dp[i][j]);
    cout << ans << "\n";
  }
  return 0;
}
