#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int par[N][N], sub[N][N];
vector<int> G[N];
int n, q;
void dfs(int root, int u, int fa) {
  par[root][u] = fa;
  sub[root][u] = 1;
  for (int v : G[u]) {
    if (v == fa) continue;
    dfs(root, v, u);
    sub[root][u] += sub[root][v];
  }
}
int g[N][N];
void bfs(int s, int dist[]) {
  memset(dist, 0x3f3f3f3f, sizeof(int) * (n + 1));
  dist[s] = 0;
  static int q[N], st, ed;
  st = ed = 0;
  q[ed++] = s;
  while (st < ed) {
    int u = q[st++];
    for (int v : G[u]) {
      if (dist[v] > dist[u] + 1) {
        dist[v] = dist[u] + 1;
        q[ed++] = v;
      }
    }
  }
}
pair<int, pair<int, int>> dat[N * N];
long long dp[N][N];
long long ans[N];
int main(int argc, char const *argv[]) {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int root = 1; root <= n; ++root) {
    ;
    dfs(root, root, root);
    bfs(root, g[root]);
  }
  int dcnt = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      dat[dcnt++] = make_pair(g[i][j], make_pair(i, j));
    }
  }
  sort(dat, dat + dcnt);
  long long Ans = 0;
  for (int i = 0; i < dcnt; ++i) {
    int u = dat[i].second.first, v = dat[i].second.second;
    dp[v][u] = dp[u][v] =
        1LL * sub[u][v] * sub[v][u] + max(dp[par[v][u]][v], dp[u][par[u][v]]);
    ans[dat[i].first] = max(ans[dat[i].first], dp[u][v]);
    Ans = max(Ans, dp[u][v]);
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      ;
  printf("%lld\n", Ans);
  return 0;
}
