#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 2e5 + 5, inf = 1e18, mod = 1000000007;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& mas) {
  for (const auto& x : mas) {
    out << x << ' ';
  }
  return out;
}
void ok() { cout << "YES" << '\n'; }
void no() { cout << "NO" << '\n'; }
inline long long nxt() {
  long long x;
  cin >> x;
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  int n = nxt();
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x = nxt() - 1, y = nxt() - 1;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<vector<pair<int, int>>> buf(n);
  vector<vector<int>> two(n, vector<int>(n));
  function<void(int, int, int, int)> dfs = [&](int v, int p, int d, int start) {
    buf[d].push_back({start, v});
    two[start][v] = p;
    for (auto& u : g[v]) {
      if (u != p) dfs(u, v, d + 1, start);
    }
  };
  for (int i = 0; i < n; i++) {
    dfs(i, -1, 0, i);
  }
  vector<vector<long long>> cntV(n, vector<long long>(n));
  function<void(int, int, int)> calc = [&](int v, int p, int start) {
    cntV[start][v] = 1;
    for (auto& u : g[v]) {
      if (u == p) continue;
      calc(u, v, start);
      cntV[start][v] += cntV[start][u];
    }
  };
  for (int i = 0; i < n; i++) {
    calc(i, -1, i);
  }
  vector<vector<long long>> dp(n, vector<long long>(n));
  for (int i = 1; i < n; i++) {
    for (auto& [v, u] : buf[i]) {
      int p1 = two[v][u];
      int p2 = two[u][v];
      int cur = cntV[u][v] * cntV[v][u];
      dp[v][u] = max(dp[v][p1], dp[u][p2]) + cur;
    }
  }
  long long ans = 0;
  for (auto& vect : buf) {
    for (auto& [v, u] : vect) {
      ans = max(ans, dp[v][u]);
    }
  }
  cout << ans;
  return 0;
}
