#include <bits/stdc++.h>
using namespace std;
const long long N = 3002;
long long timer = 0;
long long used[N];
vector<long long> g[N];
long long h[N];
long long p[N];
long long tin[N];
long long tout[N];
long long lca[N][N];
long long pr[N][N];
vector<long long> sub[N];
void dfs(long long cur, long long ch, long long prt) {
  tin[cur] = timer++;
  used[cur] = 1;
  h[cur] = ch;
  p[cur] = prt;
  lca[cur][cur] = cur;
  sub[cur].push_back(cur);
  for (auto t : g[cur]) {
    if (!used[t]) {
      dfs(t, ch + 1, cur);
      for (auto x : sub[t]) {
        for (auto y : sub[cur]) {
          lca[x][y] = cur;
          lca[y][x] = cur;
          pr[y][x] = t;
        }
      }
      for (auto x : sub[t]) {
        sub[cur].push_back(x);
      }
    }
  }
  tout[cur] = timer++;
}
long long anc(long long a, long long b) {
  return tin[a] <= tin[b] && tout[b] <= tout[a];
}
long long n;
long long gtt(long long x, long long y) {
  if (!anc(x, y) && !anc(y, x)) {
    return (long long)sub[x].size() * (long long)sub[y].size();
  }
  if (!anc(x, y)) {
    swap(x, y);
  }
  return (long long)(n - sub[pr[x][y]].size()) * (sub[y].size());
}
long long dp[N][N];
long long calc(long long a, long long b) {
  if (dp[a][b] != -1) return dp[a][b];
  long long clen = h[a] + h[b] - 2 * h[lca[a][b]];
  if (clen == 0) {
    dp[a][b] = 0;
  } else {
    if (!anc(a, b) && !anc(b, a)) {
      dp[a][b] = max(calc(a, p[b]), calc(p[a], b));
    } else if (anc(a, b)) {
      dp[a][b] = max(calc(pr[a][b], b), calc(a, p[b]));
    } else {
      dp[a][b] = max(calc(pr[b][a], a), calc(b, p[a]));
    }
    dp[a][b] += gtt(a, b);
  }
  return dp[a][b];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, 0, -1);
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      dp[i][j] = -1;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      ans = max(ans, calc(i, j));
    }
  }
  cout << ans << endl;
}
