#include <bits/stdc++.h>
using namespace std;
template <class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
void setmax(T& a, T b) {
  a = max(a, b);
};
template <typename T>
void setmin(T& a, T b) {
  a = min(a, b);
};
const int N = 3010;
int n;
vector<int> g[N];
long long sz[N][N];
int par[N][N];
long long dp[N][N];
void dfs(int root, int x, int p = 0) {
  sz[root][x]++;
  par[root][x] = p;
  for (int y : g[x]) {
    if (y == p) continue;
    dfs(root, y, x);
    sz[root][x] += sz[root][y];
  }
}
long long solve(int u, int v) {
  if (dp[u][v] != -1) return dp[u][v];
  if (u > v) return dp[u][v] = solve(v, u);
  if (u == v) return dp[u][v] = 0;
  return dp[u][v] = sz[u][v] * sz[v][u] +
                    max(solve(par[v][u], v), solve(u, par[u][v]));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, i);
  }
  memset(dp, -1, sizeof dp);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      setmax(ans, solve(i, j));
    }
  }
  cout << ans << '\n';
  return 0;
}
