#include <bits/stdc++.h>
using namespace std;
const int mx = 3003;
vector<int> vec[mx];
int sub[mx][mx];
int par[mx][mx];
long long dp[mx][mx];
int arrx[mx], arry[mx];
void dfs(int root, int u, int from) {
  par[root][u] = from;
  int i, v, l = vec[u].size();
  for (i = 0; i < l; i++) {
    v = vec[u][i];
    if (v == from) continue;
    dfs(root, v, u);
    sub[root][u] += sub[root][v];
  }
  sub[root][u]++;
}
long long func(int x, int y) {
  if (dp[x][y] != -1) return dp[x][y];
  int i, j, u, v, l, now;
  long long ret = 0, ans;
  int prx = par[y][x];
  int pry = par[x][y];
  l = vec[x].size();
  for (i = 0; i < l; i++) {
    v = vec[x][i];
    if (v == prx) continue;
    ret = max(ret, func(v, y));
  }
  l = vec[y].size();
  for (i = 0; i < l; i++) {
    v = vec[y][i];
    if (v == pry) continue;
    ret = max(ret, func(x, v));
  }
  ans = (long long)sub[x][y] * sub[y][x];
  ans += ret;
  return dp[x][y] = ans;
}
int main() {
  int i, j, n, k, u, v, p, q;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    vec[u].push_back(v);
    vec[v].push_back(u);
    arrx[i] = u;
    arry[i] = v;
  }
  for (i = 1; i <= n; i++) {
    dfs(i, i, -1);
  }
  long long ans = 0;
  memset(dp, -1, sizeof(dp));
  for (i = 1; i < n; i++) {
    ans = max(ans, func(arrx[i], arry[i]));
  }
  printf("%lld\n", ans);
  return 0;
}
