#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx")
using namespace std;
template <typename T>
void uin(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
void uax(T &a, T b) {
  if (b > a) a = b;
}
const long long N = 3003;
long long n;
long long dp[N][N];
long long sub[N][N];
long long par[N][N];
bool used[N][N];
vector<long long> g[N];
void dfs(long long v, long long s, long long pr = -1) {
  par[v][s] = pr;
  sub[v][s] = 1;
  for (long long to : g[v]) {
    if (to != pr) {
      dfs(to, s, v);
      sub[v][s] += sub[to][s];
    }
  }
}
long long DP(long long u, long long v) {
  if (used[u][v]) return dp[u][v];
  used[u][v] = 1;
  if (u == v) return 0;
  uax(dp[u][v], DP(par[u][v], v) + sub[u][v] * sub[v][u]);
  uax(dp[u][v], DP(u, par[v][u]) + sub[u][v] * sub[v][u]);
  return dp[u][v];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (long long i = 1; i <= n; ++i) {
    dfs(i, i);
  }
  long long answer = 0;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = i + 1; j <= n; ++j) {
      uax(answer, DP(i, j));
    }
  }
  cout << answer << '\n';
  return 0;
}
