#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tos(T a) {
  stringstream ss;
  string ret;
  ss << a;
  ss >> ret;
  return ret;
}
void read(int &_a) { int temp = scanf("%d", &_a); }
void read(int &_a, int &_b) { int temp = scanf("%d %d", &_a, &_b); }
void read(int &_a, int &_b, int &_c) {
  int temp = scanf("%d %d %d", &_a, &_b, &_c);
}
const int SZ = 3000 + 7;
int N, P[SZ][SZ], C[SZ][SZ];
vector<int> AJ[SZ];
long long memo[SZ][SZ];
void dfs(int r, int u, int p) {
  P[r][u] = p;
  C[r][u] = 1;
  int l = AJ[u].size();
  for (int(x) = (0); (x) < (l); (x)++) {
    int v = AJ[u][x];
    if (v == p) continue;
    dfs(r, v, u);
    C[r][u] += C[r][v];
  }
}
long long calc(int u, int v) {
  if (u == v) return 0;
  long long &ret = memo[u][v];
  if (-1 != ret) return ret;
  ret = C[u][v] * C[v][u] + max(calc(u, P[u][v]), calc(P[v][u], v));
  return ret;
}
int main() {
  while (cin >> N) {
    memset(P, -1, sizeof P);
    ;
    memset(C, 0, sizeof C);
    ;
    for (int(x) = (0); (x) < (SZ); (x)++) AJ[x].clear();
    int u, v;
    memset(memo, -1, sizeof memo);
    ;
    for (int(x) = (1); (x) < (N); (x)++) {
      read(u, v);
      u--;
      v--;
      AJ[u].push_back(v);
      AJ[v].push_back(u);
    }
    for (int(u) = (0); (u) < (N); (u)++) dfs(u, u, -1);
    long long ans = 0ll;
    for (int(u) = (0); (u) < (N); (u)++)
      for (int(v) = (0); (v) < (N); (v)++) ans = max(ans, calc(u, v));
    cout << ans << endl;
  }
  return 0;
}
