#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using cd = complex<double>;
constexpr int maxn = 3000 + 10;
bitset<maxn> done[maxn] = {};
int n, ret = 0;
vector<int> vec[maxn];
int sz_buf[maxn][maxn] = {}, tt[maxn][maxn] = {};
ll dyn[maxn][maxn] = {};
void calc_tt(int me, int val, int root) {
  tt[root][me] = val;
  for (auto next : vec[me])
    if (next != val) calc_tt(next, me, root);
}
int calc_sz(int x, int y) {
  if (!sz_buf[x][y]) {
    sz_buf[x][y] = 1;
    for (auto z : vec[y]) {
      if (z != x) {
        sz_buf[x][y] += calc_sz(y, z);
      }
    }
  }
  return sz_buf[x][y];
}
void calc(int x, int y) {
  if (!done[x][y] && tt[x][y] == x) {
    dyn[x][y] = dyn[y][x] = calc_sz(tt[x][y], y) * calc_sz(tt[y][x], x);
  }
  if (!done[x][y] && tt[x][y] != x) {
    done[x][y] = 1;
    calc(x, tt[x][y]);
    calc(y, tt[y][x]);
    dyn[x][y] = dyn[y][x] = max(dyn[x][tt[x][y]], dyn[y][tt[y][x]]) +
                            calc_sz(tt[x][y], y) * calc_sz(tt[y][x], x);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0, x, y; i < n - 1; ++i) {
    cin >> x >> y;
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) calc_tt(i, -1, i);
  ll ret = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) {
      calc(i, j);
      ret = max<ll>(ret, dyn[i][j]);
    }
  cout << ret << endl;
  return 0;
}
