#include <bits/stdc++.h>
using namespace std;
const int N = 3030, L = 17;
int n, p[N][L], dep[N];
vector<int> adj[N];
int sz[N];
void DFS(int u, int par) {
  p[u][0] = par;
  dep[u] = 1 + dep[par];
  sz[u] = 1;
  for (auto v : adj[u])
    if (v != par) {
      DFS(v, u);
      sz[u] += sz[v];
    }
}
int jump(int u, int k) {
  for (int i = 0; i < L; i++)
    if (k & (1 << i)) u = p[u][i];
  return u;
}
int LCA(int u, int v) {
  if (u == v) return u;
  if (dep[u] < dep[v]) swap(u, v);
  int dif = dep[u] - dep[v];
  u = jump(u, dif);
  if (u == v) return u;
  for (int i = L - 1; i >= 0; i--)
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  return p[u][0];
}
vector<pair<int, int> > v;
long long mem[N][N];
int f(int u, int v) {
  int lca = LCA(u, v);
  if (u == lca || v == lca) {
    int x = (u != lca) ? v : u;
    int y = (u == lca) ? v : u;
    int k = dep[y] - dep[x];
    int z = jump(y, k - 1);
    return sz[y] * (sz[1] - sz[z]);
  }
  return sz[u] * sz[v];
}
long long dp(int u, int v, int pu, int pv) {
  long long &ret = mem[u][v];
  if (ret != -1) return ret;
  ret = 0;
  for (auto x : adj[u]) {
    if (x == pu) continue;
    ret = max(ret, dp(x, v, u, pv) + f(x, v));
  }
  for (auto x : adj[v]) {
    if (x == pv) continue;
    ret = max(ret, dp(u, x, pu, v) + f(x, u));
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
    v.push_back({a, b});
  }
  DFS(1, 0);
  for (int j = 1; j < L; j++)
    for (int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  long long ans = 0;
  memset(mem, -1, sizeof mem);
  for (auto p : v)
    ans = max(ans,
              dp(p.first, p.second, p.second, p.first) + f(p.first, p.second));
  printf("%lld", ans);
}
