#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
vector<int> E[maxn];
long long dp[maxn][maxn], par[maxn][maxn], siz[maxn][maxn];
void dfs1(int x, int t) {
  siz[t][x] = 1;
  dp[t][x] = -1;
  for (auto i : E[x]) {
    if (i == par[t][x]) continue;
    par[t][i] = x;
    dfs1(i, t);
    siz[t][x] += siz[t][i];
  }
}
long long dfs(int x, int y) {
  if (x == y) dp[x][y] = 0;
  if (dp[x][y] != -1) return dp[x][y];
  dp[x][y] = max(dfs(par[y][x], y), dfs(par[x][y], x)) + siz[x][y] * siz[y][x];
  return dp[x][y];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    E[x].push_back(y);
    E[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) dfs1(i, i);
  long long res = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) res = max(res, dfs(i, j));
  cout << res << endl;
}
