#include <bits/stdc++.h>
using namespace std;
long long int dp[3001][3001];
vector<long long int> G[3001];
bool used[3001], used1[3001], used2[3001];
long long int arr[3001][3001];
long long int par[3001][3001];
long long int dfs(int s, int v) {
  if (s > v) {
    swap(s, v);
  }
  if (dp[s][v] != -1) {
    return dp[s][v];
  }
  dp[s][v] = arr[s][v] * arr[v][s] + max(dfs(s, par[s][v]), dfs(par[v][s], v));
  return dp[s][v];
}
void dfs2(long long int s, long long int v) {
  used2[v] = 1;
  long long int ans = 0;
  for (long long int i = 0; i < G[v].size(); i++) {
    if (!used2[G[v][i]]) {
      par[s][G[v][i]] = v;
      if (G[G[v][i]].size() == 1) {
        used2[G[v][i]] = 1;
        arr[s][G[v][i]] = 1;
        ans++;
      } else {
        dfs2(s, G[v][i]);
        ans = ans + arr[s][G[v][i]];
      }
    }
  }
  ans++;
  arr[s][v] = ans;
}
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      dp[i][j] = -1;
    }
  }
  for (int i = 1; i <= n; i++) {
    dp[i][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      used[i] = 0;
      used1[i] = 0;
      used2[i] = 0;
    }
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      used2[j] = 0;
    }
    dfs2(i, i);
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      dfs(i, j);
    }
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << "\n";
}
