#include <bits/stdc++.h>
using namespace std;
const int maxn = 3007;
const int inf = INT_MAX;
const long long inff = 1e18;
const long long mod = 1e9 + 7;
int n, x, y;
vector<int> G[maxn];
int siz[maxn], depth[maxn];
long long dp[maxn][maxn];
pair<int, int> last1[maxn][maxn], last2[maxn][maxn];
vector<pair<int, int> > tmp[maxn];
void dfs0(int now, int p) {
  siz[now] = 1;
  for (int i : G[now]) {
    if (i != p) {
      depth[i] = depth[now] + 1;
      dfs0(i, now);
      siz[now] += siz[i];
    }
  }
}
vector<int> v, u;
void dfs(int s, int now, int p, int dep) {
  u.push_back(now);
  if (p != -1) {
    if (v[0] == 0 && v.back() == 0)
      dp[now][s] = dp[s][now] =
          siz[s] * 1ll * (n - siz[u[((int)(u).size()) - 2]]);
    if (v[0] == 0 && v.back() == 1)
      dp[now][s] = dp[s][now] = siz[s] * 1ll * siz[now];
    if (v[0] == 1 && v.back() == 1)
      dp[now][s] = dp[s][now] = (n - siz[u[1]]) * 1ll * siz[now];
    if (last1[s][now].first == 0) {
      last1[s][now] = make_pair(p, s);
      last1[now][s] = make_pair(p, s);
    } else {
      last2[now][s] = make_pair(p, s);
      last2[s][now] = make_pair(p, s);
    }
    if (s < now) tmp[dep].push_back(make_pair(s, now));
  }
  for (int i : G[now]) {
    if (i != p) {
      if (depth[i] < depth[now])
        v.push_back(0);
      else
        v.push_back(1);
      dfs(s, i, now, dep + 1);
      v.pop_back();
    }
  }
  u.pop_back();
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(last1, 0, sizeof(last1));
  memset(last2, 0, sizeof(last2));
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs0(1, -1);
  for (int i = 1; i <= n; i++) {
    vector<int>().swap(u);
    vector<int>().swap(v);
    dfs(i, i, -1, 0);
  }
  long long ans = 0ll;
  for (pair<int, int> i : tmp[1]) ans = max(ans, dp[i.first][i.second]);
  for (int i = 2; i <= n; i++)
    for (pair<int, int> j : tmp[i]) {
      dp[j.first][j.second] += max(
          dp[last1[j.first][j.second].first][last1[j.first][j.second].second],
          dp[last2[j.first][j.second].first][last2[j.first][j.second].second]);
      dp[j.second][j.first] = dp[j.first][j.second];
      ans = max(ans, dp[j.first][j.second]);
    }
  cout << ans << '\n';
}
