#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 3;
int n, sz[N];
long long ans, dp[N][N];
int tin[N], tout[N], timer, pp[N];
int used[N][N], tor[N][N], len[N][N];
vector<int> g[N];
void getsz(int v, int pr = 0) {
  tin[v] = ++timer;
  sz[v] = 1;
  pp[v] = pr;
  for (int to : g[v]) {
    if (to == pr) continue;
    getsz(to, v);
    sz[v] += sz[to];
  }
  tout[v] = timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
long long ff(int a, int b, int ll) {
  if (upper(a, b)) {
    return ll * 1ll * (n - sz[tor[a][b]]) * sz[b];
  } else if (upper(b, a)) {
    swap(a, b);
    return ll * 1ll * (n - sz[tor[a][b]]) * sz[b];
  } else {
    return sz[a] * 1ll * sz[b] * ll;
  }
}
long long fun(int a, int b) {
  if (a == b) return 0ll;
  if (a > b) swap(a, b);
  if (used[a][b]) {
    return dp[a][b];
  }
  used[a][b] = 1;
  dp[a][b] = max(fun(tor[a][b], b), fun(a, tor[b][a])) + ff(a, b, len[a][b]) -
             ff(a, b, len[a][b] - 1);
  ans = max(ans, dp[a][b]);
  return dp[a][b];
}
void dfs(int v, int x, int tt, int pr, int ll) {
  tor[x][v] = tt;
  len[x][v] = ll;
  for (int to : g[v]) {
    if (to == pr) continue;
    dfs(to, x, tt, v, ll + 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  getsz(1);
  for (int i = 1; i <= n; i++) {
    for (int to : g[i]) {
      len[i][to] = 1;
      dfs(to, i, to, i, 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      fun(i, j);
    }
  }
  cout << ans << endl;
}
