#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> add_pair(pair<long long, long long> a,
                                    pair<long long, long long> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
long long power(long long a, long long b) {
  long long res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
      b--;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long fermat_inv(long long y) { return power(y, 1000000007 - 2); }
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
vector<vector<long long> > G(3005, vector<long long>());
long long par[3005][3005], sub[3005][3005], dp[3005][3005];
long long dfs(long long root, long long parent, long long R) {
  long long cnt = 1;
  par[R][root] = parent;
  for (auto it = (G[root]).begin(); it != (G[root]).end(); it++) {
    if (*it != parent) {
      cnt += dfs(*it, root, R);
    }
  }
  sub[R][root] = cnt;
  return cnt;
}
long long solve(long long u, long long v) {
  if (dp[u][v] != -1ll) return dp[u][v];
  if (u == v) {
    dp[u][v] = 0;
    return 0;
  }
  dp[u][v] =
      sub[u][v] * sub[v][u] + max(solve(u, par[u][v]), solve(par[v][u], v));
  return dp[u][v];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long u, v, mx, a, b, i, j, n, m, ans = 0;
  cin >> n;
  for (i = (0); i < (n - 1); i += (1)) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (i = (0); i < (n); i += (1)) dfs(i + 1, i + 1, i + 1);
  for (i = (0); i < (n); i += (1))
    for (j = (0); j < (n); j += (1)) dp[i + 1][j + 1] = -1;
  for (i = (0); i < (n + 1); i += (1)) {
    for (j = (0); j < (n + 1); j += (1)) {
      ans = max(ans, solve(i + 1, j + 1));
    }
  }
  cout << ans << '\n';
  return 0;
}
