#include <bits/stdc++.h>
using namespace std;
mt19937 rng(static_cast<unsigned int>(
    chrono::steady_clock::now().time_since_epoch().count()));
template <typename num_t>
inline void add_mod(num_t& a, const long long& b, const int& m) {
  a = (a + b) % m;
  if (a < 0) a += m;
}
template <typename num_t>
inline void unsafe_add_mod(num_t& a, const long long& b, const int& m) {
  a += b;
  if (a < 0)
    a += m;
  else if (a >= m)
    a -= m;
}
template <typename num_t>
inline bool update_max(num_t& a, const num_t& b) {
  return a < b ? a = b, true : false;
}
template <typename num_t>
inline bool update_min(num_t& a, const num_t& b) {
  return a > b ? a = b, true : false;
}
template <typename num_t>
num_t gcd(const num_t& lhs, const num_t& rhs) {
  return !lhs ? rhs : gcd(rhs % lhs, lhs);
}
template <typename num_t>
num_t lcm(const num_t& lhs, const num_t& rhs) {
  return lhs / ::gcd(lhs, rhs) * rhs;
}
template <typename num_t>
num_t pw(num_t n, num_t k, const num_t& mod) {
  if (k == -1) k = mod - 2;
  num_t res = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) res = 1ll * res * n % mod;
    n = 1ll * n * n % mod;
  }
  return res % mod;
}
const int inf = 1e9 + 7;
const int mod = 998244353;
const long long ll_inf = (long long)inf * inf * 9 + 7;
const int maxn = 3000 + 7;
int n;
vector<int> adj[maxn];
int depth[maxn];
int lhs[maxn], rhs[maxn];
int parent[maxn][maxn];
int dist[maxn][maxn];
long long cost[maxn][maxn];
int f[maxn];
vector<pair<int, int> > sub_pair[maxn];
void dfs(int u, int root) {
  static int cnt = 0;
  lhs[u] = rhs[u] = ++cnt;
  if (root == -1)
    depth[u] = 0;
  else
    depth[u] = depth[root] + 1;
  parent[u][0] = u;
  parent[u][1] = root;
  for (int j = (2), _b = (maxn); j < _b; ++j) {
    if (parent[u][j - 1] == -1)
      parent[u][j] = -1;
    else
      parent[u][j] = parent[parent[u][j - 1]][1];
  }
  f[u] = 1;
  for (int v : adj[u])
    if (v != root) {
      dfs(v, u);
      update_max(rhs[u], rhs[v]);
      f[u] += f[v];
    }
}
void get_dist(int u, int parent, int cur, int root) {
  dist[root][u] = cur;
  for (int v : adj[u])
    if (v != parent) {
      get_dist(v, u, cur + 1, root);
    }
}
bool is_parent(int u, int v) { return lhs[u] <= lhs[v] && rhs[v] <= rhs[u]; }
void solve() {
  cin >> n;
  for (int i = (1), _b = (n); i < _b; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) get_dist(i, -1, 0, i);
  dfs(1, -1);
  auto get_sub_cost = [&](int u, int v) -> long long {
    if (is_parent(v, u)) swap(u, v);
    if (is_parent(u, v)) {
      int diff = depth[v] - depth[u] - 1;
      return (n - f[parent[v][diff]]) * f[v];
    } else {
      return f[u] * f[v];
    }
  };
  auto update_cost = [&](int u, int v, long long temp) {
    if (u > v) swap(u, v);
    update_max(cost[u][v], temp);
  };
  auto get_cost = [&](int u, int v) -> long long {
    if (u <= v)
      return cost[u][v];
    else
      return cost[v][u];
  };
  for (int u = 1; u <= n; ++u)
    for (int v = u + 1; v <= n; ++v) {
      sub_pair[dist[u][v]].push_back({u, v});
      cost[u][v] = get_sub_cost(u, v);
    }
  for (int len = n - 1; len > 0; --len) {
    for (auto p : sub_pair[len]) {
      int u = p.first, v = p.second;
      if (is_parent(v, u)) swap(u, v);
      if (is_parent(u, v)) {
        int v1 = parent[v][1];
        int u1 = parent[v][depth[v] - depth[u] - 1];
        update_cost(u1, v, get_cost(u, v) + get_sub_cost(u1, v));
        update_cost(u, v1, get_cost(u, v) + get_sub_cost(u, v1));
      } else {
        int u1 = parent[u][1];
        int v1 = parent[v][1];
        update_cost(u1, v, get_cost(u, v) + get_sub_cost(u1, v));
        update_cost(u, v1, get_cost(u, v) + get_sub_cost(u, v1));
      }
    }
  }
  long long best = 0;
  for (auto p : sub_pair[1]) {
    update_max(best, get_cost(p.first, p.second));
  }
  cout << best << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test) cin >> test;
  for (int i = 0; i < test; ++i) {
    solve();
  }
}
