#include <bits/stdc++.h>
using namespace std;
long long n, cnt = 0, u, v, root, ans = 0;
long long head[3005], f[3005][3005], s[3005][3005], dp[3005][3005];
struct edge {
  long long next;
  long long to;
} e[6005];
inline void add_edge(long long u, long long v) {
  cnt++;
  e[cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt;
}
inline void dfs(long long now, long long fath) {
  f[root][now] = fath, s[root][now] = 1;
  for (long long i = head[now]; i; i = e[i].next) {
    if (e[i].to != fath) dfs(e[i].to, now), s[root][now] += s[root][e[i].to];
  }
}
inline long long DP(long long x, long long y) {
  if (x == y) return dp[x][y] = 0;
  if (dp[x][y]) return dp[x][y];
  return dp[x][y] = max(DP(x, f[x][y]), DP(y, f[y][x])) + s[x][y] * s[y][x];
}
signed main() {
  cin >> n;
  for (long long i = 1; i < n; i++) {
    cin >> u >> v;
    add_edge(u, v), add_edge(v, u);
  }
  for (long long i = 1; i <= n; i++) root = i, dfs(i, 0);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) DP(i, j), ans = max(ans, dp[i][j]);
  }
  cout << ans << endl;
  return 0;
}
