#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using iii = tuple<int, int, int>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for (int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  vector<vector<int>> C(N, vector<int>(N, -1));
  vector<vector<ll>> D(N, vector<ll>(N, -1));
  function<int(int, int)> g = [&](int p, int i) {
    int& m = C[p][i];
    if (~m) return m;
    m = 1;
    for (int j : G[i])
      if (j != p) m += g(i, j);
    return m;
  };
  function<ll(int, int, int, int)> f = [&](int p, int q, int i, int j) {
    ll& m = D[i][j];
    if (~m) return m;
    ll c = g(p, i) * ll(g(q, j));
    m = c;
    for (int k : G[i])
      if (k != p) m = max(m, f(i, q, k, j) + c);
    for (int k : G[j])
      if (k != q) m = max(m, f(p, j, i, k) + c);
    return m;
  };
  ll m = 0;
  for (int i = 0; i < N; i++)
    for (int j : G[i]) m = max(m, f(j, i, i, j));
  cout << m;
}
