#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3000;
int Size[MaxN + 5], f[MaxN + 5], S[MaxN + 5], n, dep[MaxN + 5];
vector<int> G[MaxN + 5];
bool vis[MaxN + 5][MaxN + 5];
long long dp[MaxN + 5][MaxN + 5], ans, res;
pair<int, int> del[MaxN + 5][MaxN + 5];
queue<pair<int, int> > q;
void Dfs(int x, int fa) {
  f[x] = fa;
  int y;
  S[x] = G[x].size();
  y = fa;
  Size[x] = 1;
  while (y != -1) {
    vis[y][x] = true;
    y = f[y];
  }
  for (int i = 0; i < S[x]; ++i) {
    y = G[x][i];
    if (y != fa) {
      dep[y] = dep[x] + 1;
      Dfs(y, x);
      Size[x] += Size[y];
    }
  }
  return;
}
long long CAL(pair<int, int> nxt) {
  long long val = max(dp[del[nxt.first][nxt.second].first][nxt.second],
                      dp[nxt.first][del[nxt.first][nxt.second].second]);
  if (vis[nxt.first][nxt.second])
    return val +
           Size[nxt.second] * (n - Size[del[nxt.first][nxt.second].first]);
  else if (vis[nxt.second][nxt.first])
    return val +
           Size[nxt.first] * (n - Size[del[nxt.first][nxt.second].second]);
  return val + Size[nxt.first] * Size[nxt.second];
}
int main() {
  int u, v;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    G[i].clear();
    for (int j = 1; j <= n; ++j) vis[i][j] = false, dp[i][j] = 0;
  }
  pair<int, int> now, nxt;
  for (int i = 1; i < n; ++i) {
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
    if (u < v)
      now.first = u, now.second = v;
    else
      now.first = v, now.second = u;
    del[now.first][now.second].first = now.second;
    del[now.first][now.second].second = now.first;
    q.push(now);
  }
  dep[1] = 1;
  Dfs(1, -1);
  ans = 0;
  while (!q.empty()) {
    now = q.front();
    q.pop();
    dp[now.first][now.second] = CAL(now);
    ans = max(ans, dp[now.first][now.second]);
    dp[now.second][now.first] = dp[now.first][now.second];
    for (int i = 0; i < S[now.first]; ++i) {
      v = G[now.first][i];
      if (v == del[now.first][now.second].first) continue;
      if (v < now.second) {
        nxt.first = v, nxt.second = now.second;
        del[nxt.first][nxt.second].first = now.first;
        if (del[nxt.first][nxt.second].second == 0) q.push(nxt);
      } else {
        nxt.first = now.second, nxt.second = v;
        del[nxt.first][nxt.second].second = now.first;
        if (del[nxt.first][nxt.second].first == 0) q.push(nxt);
      }
    }
    for (int i = 0; i < S[now.second]; ++i) {
      v = G[now.second][i];
      if (v == del[now.first][now.second].second) continue;
      if (v < now.first) {
        nxt.first = v, nxt.second = now.first;
        del[nxt.first][nxt.second].first = now.second;
        if (del[nxt.first][nxt.second].second == 0) q.push(nxt);
      } else {
        nxt.first = now.first, nxt.second = v;
        del[nxt.first][nxt.second].second = now.second;
        if (del[nxt.first][nxt.second].first == 0) q.push(nxt);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
