#include <bits/stdc++.h>
using namespace std;
long long mod = (1000000007LL);
inline long long poww(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
inline pair<long long, long long> operator+(pair<long long, long long> A,
                                            pair<long long, long long> B) {
  return pair<long long, long long>(A.first + B.first, A.second + B.second);
}
inline pair<long long, long long> operator-(pair<long long, long long> A,
                                            pair<long long, long long> B) {
  return pair<long long, long long>(A.first - B.first, A.second - B.second);
}
inline long long mult(long long a, long long b) { return (a * b) % mod; }
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long n, m, q, k, v[3050];
pair<long long, long long> TT, w[3050];
string second;
long long sz[3050][3050], pai[3050][3050];
vector<long long> grafo[3050];
void dfs(long long x, long long p, long long root) {
  sz[root][x] = 1;
  pai[root][x] = p;
  for (auto v : grafo[x]) {
    if (v != p) {
      dfs(v, x, root);
      sz[root][x] += sz[root][v];
    }
  }
}
long long dp[3050][3050];
long long solve(long long u, long long v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  long long A = (pai[u][v] != v ? sz[u][v] * sz[v][u] + solve(u, pai[u][v])
                                : -1000000000000000);
  long long B = (pai[v][u] != u ? sz[u][v] * sz[v][u] + solve(pai[v][u], v)
                                : -1000000000000000);
  return dp[u][v] = max(A, B);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> n;
  for (long long i = 1, a, b; i < n; i++) {
    cin >> a >> b;
    grafo[a].push_back(b);
    grafo[b].push_back(a);
  }
  for (long long i = 1; i <= n; i++) dfs(i, i, i);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++) ans = max(ans, solve(i, j));
  }
  cout << ans << "\n";
}
