#include <bits/stdc++.h>
const long long M = 1e6 + 10;
const long long N = 3010;
using namespace std;
inline long long read() {
  long long sum = 0, b = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') b = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    sum = sum * 10 + c - 48;
    c = getchar();
  }
  return sum * b;
}
long long par[N][N], sub[N][N];
long long dp[N][N];
vector<int> tree[N];
long long n;
void dfs(long long root, long long u) {
  int i, j;
  bool flag = false;
  sub[root][u] = 1;
  for (i = 0; i < tree[u].size(); i++) {
    long long v = tree[u][i];
    if (v == par[root][u]) continue;
    flag = true;
    par[root][v] = u;
    dfs(root, v);
    sub[root][u] += sub[root][v];
  }
  return;
}
void init() {
  int i, j;
  for (i = 1; i <= n; i++) {
    sub[i][i] = 1;
    dfs(i, i);
  }
}
long long get_dp(long long i, long long j) {
  if (dp[i][j]) return dp[i][j];
  if (i == j) return 0;
  return dp[i][j] = sub[i][j] * sub[j][i] +
                    max(get_dp(par[j][i], j), get_dp(i, par[i][j]));
}
int main() {
  int i, j;
  n = read();
  for (i = 1; i < n; i++) {
    long long x = read(), y = read();
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
  init();
  long long ans = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      get_dp(i, j);
      ans = max(ans, dp[i][j]);
    }
  printf("%lld", ans);
  return 0;
}
