#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
  if (a < b) a = b;
}
const long long MOD = 1e9 + 7;
const long long MAX = 200020;
const double pi = acos(-1);
const double EPS = 1e-12;
const long long INF = 1e18;
const long long MAX_V = 3020;
const long long MAX_LOG_V = 15;
vector<long long> G[MAX_V];
long long root;
long long parent[MAX_LOG_V][MAX_V];
long long depth[MAX_V];
void dfs(long long v, long long p, long long d) {
  parent[0][v] = p;
  depth[v] = d;
  for (long long i = 0; i < G[v].size(); i++) {
    if (G[v][i] != p) dfs(G[v][i], v, d + 1);
  }
}
void init(long long V) {
  dfs(root, -1, 0);
  for (long long k = 0; k + 1 < MAX_LOG_V; k++) {
    for (long long v = 0; v < V; v++) {
      if (parent[k][v] < 0)
        parent[k + 1][v] = -1;
      else
        parent[k + 1][v] = parent[k][parent[k][v]];
    }
  }
}
long long lca(long long u, long long v) {
  if (depth[u] > depth[v]) {
    swap(u, v);
  }
  for (long long k = 0; k < MAX_LOG_V; k++) {
    if ((depth[v] - depth[u]) >> k & 1) {
      v = parent[k][v];
    }
  }
  if (u == v) return u;
  for (long long k = MAX_LOG_V - 1; k >= 0; k--) {
    if (parent[k][u] != parent[k][v]) {
      u = parent[k][u];
      v = parent[k][v];
    }
  }
  return parent[0][u];
}
long long SIZE[3030][3030];
long long calc_size(long long par, long long n, long long pre) {
  long long res = 1;
  for (auto nxt : G[n]) {
    if (nxt == pre) continue;
    res += calc_size(par, nxt, n);
  }
  SIZE[par][n] = res;
  return res;
}
long long N;
long long dp[3030][3030];
long long calc_dp(long long u, long long v) {
  if (dp[u][v] != 0) return dp[u][v];
  if (u == v) {
    return 0;
  }
  long long par = lca(u, v);
  if (par != u && par != v) {
    long long up = parent[0][u];
    long long vp = parent[0][v];
    long long res =
        max(calc_dp(u, vp), calc_dp(up, v)) + SIZE[u][v] * SIZE[v][u];
    dp[u][v] = res;
    return res;
  } else if (par == u) {
    long long vp = parent[0][v];
    long long up = u;
    for (auto nxt : G[u]) {
      if (lca(nxt, v) == nxt && parent[0][nxt] == u) {
        up = nxt;
        break;
      }
    }
    long long res =
        max(calc_dp(u, vp), calc_dp(up, v)) + SIZE[u][v] * SIZE[v][u];
    dp[u][v] = res;
    return res;
  } else {
    long long up = parent[0][u];
    long long vp = v;
    for (auto nxt : G[v]) {
      if (lca(nxt, u) == nxt && parent[0][nxt] == v) {
        vp = nxt;
        break;
      }
    }
    long long res =
        max(calc_dp(u, vp), calc_dp(up, v)) + SIZE[u][v] * SIZE[v][u];
    dp[u][v] = res;
    return res;
  }
}
void solve() {
  cin >> N;
  root = 0;
  for (long long i = 0; i < N - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  init(N);
  for (long long i = 0; i < N; ++i) {
    calc_size(i, i, i);
  }
  long long ans = 0;
  for (long long i = 0; i < N; ++i) {
    for (long long j = 0; j < N; ++j) {
      ans = max(ans, calc_dp(i, j));
    }
  }
  cout << (ans) << '\n';
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
