#include <bits/stdc++.h>
using namespace std;
const long long ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const double eps = 1e-7;
const int N = 3e3 + 228;
const long long MX = 1e17 + 17;
int n, p[N][N];
vector<int> g[N];
int sz[N][N];
bool was[N][N];
long long d[N][N];
void dfs(int v, int par, int root) {
  sz[root][v] = 1;
  p[root][v] = par;
  for (auto to : g[v])
    if (to != par) {
      dfs(to, v, root);
      sz[root][v] += sz[root][to];
    }
}
long long calc(int v, int u) {
  if (v > u) return calc(u, v);
  if (v == u) return 0;
  if (was[v][u]) return d[v][u];
  was[v][u] = 1;
  d[v][u] = max(calc(p[u][v], u), calc(v, p[v][u])) + sz[u][v] * sz[v][u];
  return d[v][u];
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  for (int i = 1; i <= n; ++i) {
    dfs(i, 0, i);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      ans = max(ans, calc(i, j));
    }
  }
  cout << ans << "\n";
  return 0;
}
