#include <bits/stdc++.h>
using namespace std;
const int maxN = 3001;
const long long oo = 1e17 + 11;
int tcases = 1;
char ch;
int readInt() {
  bool fl = 0;
  while (ch = getchar(), ch != '-' && (ch < '0' || ch > '9'))
    ;
  if (ch == '-') {
    fl = 1;
    while (ch = getchar(), ch < '0' || ch > '9')
      ;
  }
  int r = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') r = r * 10 + (ch - '0');
  return fl ? -r : r;
}
int N, M, K;
long long F[maxN][maxN], sub[maxN][maxN], w[maxN][maxN], res = 0;
int pa[maxN][maxN], dirpa[maxN], g[maxN], dist[maxN][maxN];
vector<int> e[maxN];
vector<int> cur;
void calPa(int x, int u, int p = 0, int d = 0) {
  cur.push_back(u);
  if (x != u) pa[x][u] = cur[1];
  dist[x][u] = d;
  for (int i = 0; i < e[u].size(); ++i) {
    int v = e[u][i];
    if (v == p) continue;
    calPa(x, v, u, d + 1);
  }
  cur.pop_back();
}
void dfs(int u, int p = 0) {
  dirpa[u] = p;
  g[u] = 1;
  for (int i = 0; i < e[u].size(); ++i) {
    int v = e[u][i];
    if (v == p) continue;
    dfs(v, u);
    g[u] += g[v];
  }
}
void init() {
  for (int i = 1; i <= N; ++i) {
    calPa(i, i);
  }
  dfs(1);
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < e[i].size(); ++j) {
      int v = e[i][j];
      if (v == dirpa[i]) {
        w[i][v] = g[i];
      } else {
        w[i][v] = N - g[v];
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j)
      if (i != j) {
        sub[i][j] = w[i][pa[i][j]];
      }
  }
}
long long f(int x, int y) {
  if (F[x][y] >= 0) return F[x][y];
  if (x == y) return (F[x][y] = 0);
  int l = dist[x][y];
  return (F[x][y] =
              max(f(pa[x][y], y), f(x, pa[y][x])) + sub[x][y] * sub[y][x]);
}
void testcase() {
  cin >> N;
  for (int i = 1; i < N; ++i) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  init();
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) F[i][j] = -1;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) res = max(res, f(i, j));
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  for (int i = 1; i <= tcases; ++i) testcase();
  return 0;
}
