#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[3005];
int par[14][3005];
int dep[3005];
long long int dp[3005][3005];
int sub[3005];
void dfs(int i, int p, int d) {
  dep[i] = d;
  par[0][i] = p;
  sub[i] = 1;
  for (int j = 1; j <= 13; j++) par[j][i] = par[j - 1][par[j - 1][i]];
  for (auto j : adj[i])
    if (j != p) dfs(j, i, d + 1), sub[i] += sub[j];
}
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int l = dep[x] - dep[y];
  for (int i = 13; i >= 0; i--)
    if ((1 << i) <= l) l -= (1 << i), x = par[i][x];
  if (y == x) return x;
  for (int j = 13; j >= 0; j--)
    if (par[j][x] != par[j][y]) x = par[j][x], y = par[j][y];
  return par[0][x];
}
inline int go_up(int u, int l) {
  for (int i = 13; i >= 0; i--)
    if ((1 << i) <= l) l -= (1 << i), u = par[i][u];
  return u;
}
inline int getNext(int u, int v) {
  int l = lca(u, v);
  if (l != u) return par[0][u];
  return go_up(v, dep[v] - dep[u] - 1);
}
inline int getSize(int u, int v) {
  int l = lca(u, v);
  if (l != u) return sub[u];
  return n - sub[go_up(v, dep[v] - dep[u] - 1)];
}
inline int dist(int u, int v) { return dep[u] + dep[v] - 2 * dep[lca(u, v)]; }
long long int rec(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  long long int an = (getSize(u, v) * getSize(v, u));
  an += max(rec(getNext(u, v), v), rec(u, getNext(v, u)));
  return dp[u][v] = an;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, 1, 1);
  memset(dp, -1, sizeof dp);
  long long int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans = max({ans, rec(i, j), rec(j, i)});
  cout << ans << '\n';
  return 0;
}
