#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
int n, u, v;
vector<int> adj[N];
int directParent[N][N], cnt[N][N];
void dfs1(int root, int p, int gp) {
  directParent[root][p] = gp;
  for (int ch : adj[p]) {
    if (ch == gp) continue;
    dfs1(root, ch, p);
  }
}
int dfs2(int p, int gp) {
  int ret = 1;
  for (int ch : adj[p]) {
    if (ch == gp) continue;
    ret += dfs2(ch, p);
  }
  return ret;
}
long long mem[N][N];
long long solve(int A, int B) {
  long long& ret = mem[A][B];
  if (~ret) return ret;
  int Pa = directParent[B][A];
  int Pb = directParent[A][B];
  long long cur = 1ll * cnt[Pa][A] * cnt[Pb][B];
  ret = cur;
  for (int cha : adj[A]) {
    if (cha == Pa) continue;
    ret = max(ret, solve(cha, B) + cur);
  }
  for (int chb : adj[B]) {
    if (chb == Pb) continue;
    ret = max(ret, solve(A, chb) + cur);
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) dfs1(i, i, i);
  for (int i = 1; i <= n; ++i)
    for (int j : adj[i]) cnt[i][j] = dfs2(j, i);
  long long ans = -1e18;
  memset(mem, -1, sizeof mem);
  for (int i = 1; i <= n; ++i)
    for (int j : adj[i]) ans = max(ans, solve(i, j));
  cout << ans;
  return 0;
}
