#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const long long mas = 3010;
long long kp[mas][mas], pred[mas][mas];
long long dp[mas][mas];
long long usdp[mas][mas];
long long n;
vector<long long> tree[mas];
long long us[mas];
long long in[mas];
long long timer = 0;
long long ans = 0;
void dfs(long long nac, long long u, long long v) {
  us[v] = 1;
  pred[nac][v] = u;
  in[v] = ++timer;
  for (auto i : tree[v]) {
    if (!us[i]) {
      dfs(nac, v, i);
    }
  }
  kp[nac][v] = 1 + timer - in[v];
}
void new_dp(long long u, long long v) {
  if (!usdp[pred[v][u]][v]) new_dp(pred[v][u], v);
  if (!usdp[u][pred[u][v]]) new_dp(u, pred[u][v]);
  dp[u][v] = max(dp[pred[v][u]][v], dp[u][pred[u][v]]) + kp[u][v] * kp[v][u];
  ans = max(ans, dp[u][v]);
  usdp[u][v] = 1;
}
int main() {
  fast();
  cin >> n;
  long long u, v;
  for (int i = 1; i <= n; ++i) {
    cin >> u >> v;
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) us[j] = 0;
    dfs(i, 0, i);
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) dp[i][j] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) usdp[i][j] = 0;
  }
  for (int i = 1; i <= n; ++i) usdp[i][i] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j)
      if (!usdp[i][j]) new_dp(i, j);
  }
  cout << ans;
  return 0;
}
