#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> gr[3000];
long long dp[3000][3000];
short int parent[3000][3000];
short int subtree[3000][3000];
void dfs1(int v, int par, int root) {
  parent[v][root] = par;
  for (int u : gr[v])
    if (u != par) {
      dfs1(u, v, root);
      subtree[v][root] += subtree[u][root];
    }
  subtree[v][root] += 1;
}
long long getDp(int v, int u) {
  if (v == u) return 0;
  if (dp[v][u] != -1) return dp[v][u];
  dp[v][u] = subtree[v][u] * subtree[u][v] +
             max(getDp(parent[v][u], u), getDp(v, parent[u][v]));
  return dp[v][u];
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dp[i][j] = -1;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  for (int v = 0; v < n; v++) dfs1(v, -1, v);
  long long answer = 0;
  for (int v = 0; v < n; v++)
    for (int u = 0; u < n; u++) answer = max(answer, getDp(v, u));
  cout << answer;
  return 0;
}
