#include <bits/stdc++.h>
using namespace std;
template <typename T>
void gmin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
void gmax(T &a, T b) {
  a = a > b ? a : b;
}
const int MAXN = 3010;
int n;
long long ans;
vector<int> G[MAXN];
int sz[MAXN][MAXN], fa[MAXN][MAXN];
long long dp[MAXN][MAXN];
void dfs(int x, int f, int rt) {
  sz[rt][x] = 1;
  fa[rt][x] = f;
  for (register unsigned int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    if (y == f) continue;
    dfs(y, x, rt);
    sz[rt][x] += sz[rt][y];
  }
}
long long f(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v]) return dp[u][v];
  if (dp[v][u]) return dp[v][u];
  return dp[u][v] = max(f(u, fa[u][v]), f(v, fa[v][u])) + sz[u][v] * sz[v][u];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) dfs(i, 0, i);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) gmax(ans, f(i, j));
  cout << ans << endl;
  return 0;
}
