#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10, mod = 11092019;
int n, d[N][N], sz[N][N];
long long dp[N][N];
pair<int, int> par[N][N];
vector<pair<int, int>> dist[N];
vector<int> adj[N];
void dfs(int u, int pa) {
  sz[u][pa] = 1;
  for (int v : adj[u]) {
    if (v == pa) continue;
    dfs(v, u);
    sz[u][pa] += sz[v][u];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, i);
    queue<pair<pair<int, int>, pair<int, int>>> q;
    q.push({{i, 0}, {i, i}});
    d[i][i] = 0;
    while (!q.empty()) {
      int u = q.front().first.first, w = q.front().first.second,
          br = q.front().second.first, p = q.front().second.second;
      par[i][u] = {br, p};
      q.pop();
      for (int v : adj[u]) {
        if (!d[i][v] && v != i) {
          d[i][v] = w + 1;
          if (u == i) br = v;
          q.push({{v, w + 1}, {br, u}});
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      dist[d[i][j]].push_back({i, j});
    }
  }
  long long ans = 0;
  for (int w = 1; w <= n; w++) {
    for (int i = 0; i < dist[w].size(); i++) {
      int u = dist[w][i].first, v = dist[w][i].second;
      dp[u][v] = max(dp[u][par[u][v].second], dp[par[u][v].first][v]) +
                 1ll * sz[u][par[u][v].first] * sz[v][par[u][v].second];
      ans = max(ans, dp[u][v]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
