#include <bits/stdc++.h>
using namespace std;
struct vl {
  long long x, y;
  bool operator<(const vl& t) const {
    if (x == t.x) return y < t.y;
    return x < t.x;
  }
};
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const long long MAXN = 3e3 + 69;
long long dp[MAXN][MAXN];
long long q = 1, m, n, x, y, z, k, l;
vector<long long> a[MAXN];
long long sz[MAXN][MAXN];
long long par[MAXN][MAXN];
void dfs(long long x, long long p, long long rut) {
  sz[rut][x] = 1;
  for (long long u : a[x]) {
    if (u == p) continue;
    par[rut][u] = x;
    dfs(u, x, rut);
    sz[rut][x] += sz[rut][u];
  }
}
void init() {
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) dp[i][j] = -1;
}
long long solve(long long u, long long v) {
  if (u == 0 || v == 0) return 0;
  if (u == v) {
    return 0;
  }
  if (dp[u][v] != -1) return dp[u][v];
  long long res = sz[u][v] * sz[v][u];
  res += max(solve(par[v][u], v), solve(par[u][v], u));
  dp[u][v] = res;
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    dfs(i, i, i);
  }
  init();
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans;
}
