#include <bits/stdc++.h>
using namespace std;
vector<int> a[3010];
int mem[3001][3001];
int dfs(int x, int par) {
  if (mem[x][par] != -1) {
    return mem[x][par];
  }
  mem[x][par] = 1;
  for (int i = 0; i < a[x].size(); ++i) {
    if (a[x][i] != par) {
      mem[x][par] += dfs(a[x][i], x);
    }
  }
  return mem[x][par];
}
long long mem1[3001][3001];
vector<int> b[3010];
int pa[3010];
long long dp(int x, int y, int pax, int pay) {
  if (mem1[x][y] != -1) {
    return mem1[x][y];
  }
  long long res = 0;
  int nxt;
  for (int i = 0; i < a[x].size(); ++i) {
    nxt = a[x][i];
    if (nxt == pax) continue;
    res = max(res, mem[nxt][x] * mem[y][pay] + dp(nxt, y, x, pay));
  }
  for (int i = 0; i < a[y].size(); ++i) {
    nxt = a[y][i];
    if (nxt == pay) continue;
    res = max(res, mem[nxt][y] * mem[x][pax] + dp(x, nxt, pax, y));
  }
  mem1[x][y] = res;
  return res;
}
int main() {
  int n;
  while (cin >> n) {
    long long ans = 0;
    int x, y;
    for (int i = 0; i < n - 1; ++i) {
      scanf("%d%d", &x, &y);
      a[x].push_back(y);
      a[y].push_back(x);
    }
    memset(mem, -1, sizeof mem);
    long long tmp, mx = 0, tmp1, tmp2;
    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j < a[i].size(); ++j) {
        dfs(i, a[i][j]);
        dfs(a[i][j], i);
      }
    }
    memset(mem1, -1, sizeof mem1);
    ans = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j < a[i].size(); ++j) {
        ans = max(ans, mem[i][a[i][j]] * mem[a[i][j]][i] +
                           dp(i, a[i][j], a[i][j], i));
      }
    }
    cout << ans << endl;
  }
  return 0;
}
