#include <bits/stdc++.h>
using namespace std;
long long int co = 0;
long long int ii;
vector<long long int> adj[3000];
long long int vis[3000];
long long int dp[3000][3000];
long long int par[3000][3000];
long long int ss[3000][3000];
void dfs(long long int no) {
  long long int cc = co;
  co++;
  for (long long int j = 0; j < adj[no].size(); j++) {
    long long int nn = adj[no][j];
    if (vis[nn] == 1) {
      continue;
    }
    vis[nn] = 1;
    par[ii][nn] = no;
    dfs(nn);
  }
  ss[ii][no] = co - cc;
}
long long int find(long long int a, long long int b) {
  if (dp[a][b] == -1) {
    dp[a][b] =
        ss[a][b] * ss[b][a] + max(find(par[b][a], b), find(a, par[a][b]));
    return dp[a][b];
  } else {
    return dp[a][b];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int u, v;
  for (long long int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    adj[u - 1].push_back(v - 1);
    adj[v - 1].push_back(u - 1);
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      dp[i][j] = -1;
      if (i == j) {
        dp[i][j] = 0;
      }
    }
  }
  memset(par, 0, sizeof(par));
  memset(ss, 0, sizeof(ss));
  for (long long int i = 0; i < n; i++) {
    ii = i;
    co = 0;
    memset(vis, 0, sizeof(vis));
    vis[ii] = 1;
    dfs(ii);
  }
  long long int ma = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      find(i, j);
      ma = max(ma, dp[i][j]);
    }
  }
  cout << ma << endl;
  return 0;
}
