#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<ll>> memo(3e3 + 10, vector<ll>(3e3 + 10, -1LL));
vector<vector<int>> p(3e3 + 10, vector<int>(3e3 + 10, -1));
vector<vector<int>> s(3e3 + 10, vector<int>(3e3 + 10, 1));
ll dp(int u, int v) {
  if (u == v) {
    return 0;
  }
  if (memo[u][v] != -1) return memo[u][v];
  return memo[u][v] = s[u][v] * s[v][u] + max(dp(p[v][u], v), dp(u, p[u][v]));
}
int dfs(vector<vector<int>> &g, int i, int d, int root) {
  for (int e : g[i]) {
    if (e != d) {
      p[root][e] = i;
      s[root][i] += dfs(g, e, i, root);
    }
  }
  return s[root][i];
}
signed main() {
  cin.tie(0);
  cin.sync_with_stdio();
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    dfs(g, i, -1, i);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans = max(ans, dp(i, j));
    }
  }
  cout << ans;
}
