#include <bits/stdc++.h>
using namespace std;
const int maxn = 3008;
struct edge {
  int to, nxt;
} e[maxn << 1];
int head[maxn], tot;
void add(int x, int y) {
  e[++tot].to = y;
  e[tot].nxt = head[x];
  head[x] = tot;
}
int siz[maxn][maxn], n, nxt[maxn][maxn], rt;
long long dp[maxn][maxn];
void dfs(int x) {
  siz[rt][x] = 1;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (y ^ nxt[rt][x]) {
      nxt[rt][y] = x;
      dfs(y);
      siz[rt][x] += siz[rt][y];
    }
  }
}
long long dfs2(int x, int y) {
  if (x == y) return 0;
  if (~dp[x][y]) return dp[x][y];
  dp[x][y] = max(dp[x][y], max(dfs2(x, nxt[x][y]), dfs2(y, nxt[y][x])) +
                               1ll * siz[x][y] * siz[y][x]);
  return dp[x][y];
}
int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    add(x, y);
    add(y, x);
  }
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; ++i) rt = i, dfs(i);
  long long ans = 0;
  for (int x = 1; x <= n; ++x)
    for (int y = 1; y <= n; ++y) {
      ans = max(ans, dfs2(x, y));
    }
  cout << ans;
}
