#include <bits/stdc++.h>
using namespace std;
const int maxl = 3e3 + 10;
int n, cnt;
long long ans;
int ehead[maxl];
long long son[maxl][maxl], dp[maxl][maxl];
struct node {
  int u, v, ru, lv;
};
queue<node> q;
struct ed {
  int to, nxt;
} e[maxl << 1];
bool in[maxl][maxl];
inline void add(int u, int v) {
  e[++cnt].to = v;
  e[cnt].nxt = ehead[u];
  ehead[u] = cnt;
}
inline void dfs(int u, int fa, int id) {
  int v;
  son[id][u] = 1;
  for (int i = ehead[u]; i; i = e[i].nxt) {
    v = e[i].to;
    if (v == fa) continue;
    dfs(v, u, id);
    son[id][u] += son[id][v];
  }
}
inline void prework() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= n; i++) dfs(i, 0, i);
}
inline void mainwork() {
  int u, v, nu, nv, ru, lv;
  for (u = 1; u <= n; u++)
    for (int i = ehead[u]; i; i = e[i].nxt) {
      v = e[i].to;
      if (in[u][v]) continue;
      in[u][v] = in[v][u] = true;
      dp[u][v] = dp[v][u] = son[u][v] * son[v][u];
      q.push(node{u, v, v, u});
      ans = max(dp[u][v], ans);
    }
  node d;
  while (!q.empty()) {
    d = q.front();
    q.pop();
    u = d.u;
    v = d.v;
    ru = d.ru;
    lv = d.lv;
    ans = max(ans, dp[u][v]);
    for (int i = ehead[u]; i; i = e[i].nxt) {
      nu = e[i].to;
      if (nu == ru) continue;
      dp[nu][v] = dp[v][nu] =
          max(dp[nu][v], dp[u][v] + son[nu][v] * son[v][nu]);
      if (!in[nu][v]) {
        in[nu][v] = in[v][nu] = true;
        q.push(node{nu, v, u, lv});
      }
    }
    for (int i = ehead[v]; i; i = e[i].nxt) {
      nv = e[i].to;
      if (nv == lv) continue;
      dp[u][nv] = dp[nv][u] =
          max(dp[u][nv], dp[u][v] + son[u][nv] * son[nv][u]);
      if (!in[u][nv]) {
        in[u][nv] = in[nv][u] = true;
        q.push(node{u, nv, ru, v});
      }
    }
  }
}
inline void print() { printf("%lld\n", ans); }
int main() {
  prework();
  mainwork();
  print();
  return 0;
}
