#include <bits/stdc++.h>
using namespace std;
const int md = int(1e9) + 7;
const int inf = 0x3f3f3f3f;
const long long infl = 0x3f3f3f3f3f3f3f3f;
struct edgegraph {
  int n, ecnt = 0;
  vector<int> from, to;
  vector<vector<int>> edg;
  edgegraph(int n) : n(n), edg(n) {}
  void add(int a, int b) {
    from.push_back(a);
    to.push_back(b);
    edg[a].push_back(ecnt++);
  }
  void readin(int m, bool add_both_dir) {
    int m2 = m;
    if (add_both_dir) m2 *= 2;
    from.reserve(m2);
    to.reserve(m2);
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      add(a, b);
      if (add_both_dir) add(b, a);
    }
  }
};
void solve() {
  int n;
  cin >> n;
  edgegraph g(n + 1);
  g.readin(n - 1, 1);
  vector<int> ddp(g.ecnt);
  function<int(int, int)> edfscnt = [&](int e, int n) {
    if (ddp[e]) return ddp[e];
    ddp[e] = 1;
    for (int nxe : g.edg[g.to[e]]) {
      if (g.to[nxe] == g.from[e]) continue;
      ddp[e] += edfscnt(nxe, n);
    }
    ddp[e ^ 1] = n - ddp[e];
    return ddp[e];
  };
  for (int e = 0; e < (g.ecnt); e++) edfscnt(e, n);
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, -1));
  function<long long(int, int)> edfs = [&](int e, int f) {
    int u = g.to[e], v = g.to[f];
    if (u > v) {
      swap(e, f);
      swap(u, v);
    }
    if (dp[u][v] > -1) return dp[u][v];
    dp[u][v] = 0;
    long long cur = 1LL * ddp[e] * ddp[f];
    for (int nxe : g.edg[g.to[e]]) {
      if (g.to[nxe] == g.from[e]) continue;
      dp[u][v] = max(dp[u][v], edfs(nxe, f));
    }
    for (int nxe : g.edg[g.to[f]]) {
      if (g.to[nxe] == g.from[f]) continue;
      dp[u][v] = max(dp[u][v], edfs(nxe, e));
    }
    dp[u][v] += cur;
    return dp[u][v];
  };
  long long ans = 0;
  for (int e = 0; e < (g.ecnt); e++) {
    ans = max(ans, edfs(e, e ^ 1));
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  while (tc--) solve();
  return 0;
}
