#include <bits/stdc++.h>
using namespace std;
int n, tot, head[3005], son[3005][3005], f[3005][3005];
long long dp[3005][3005];
struct node {
  int v, next;
} a[3005 << 1];
void dfs(int x, int pre, int rt) {
  son[rt][x] = 1;
  f[rt][x] = pre;
  for (int i = head[x]; i != -1; i = a[i].next) {
    int v = a[i].v;
    if (v == pre) continue;
    dfs(v, x, rt);
    son[rt][x] += son[rt][v];
  }
}
long long solve(int l, int r) {
  if (l == r) return 0;
  if (dp[l][r] != -1) return dp[l][r];
  dp[l][r] = son[l][r] * son[r][l] + max(solve(f[l][r], l), solve(f[r][l], r));
  return dp[l][r];
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d %d", &u, &v);
    a[tot] = node{v, head[u]}, head[u] = tot++;
    a[tot] = node{u, head[v]}, head[v] = tot++;
  }
  for (int i = 1; i <= n; i++) dfs(i, 0, i);
  long long ans = 0;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      ans = max(ans, solve(i, j));
    }
  }
  printf("%lld\n", ans);
  return 0;
}
