#include <bits/stdc++.h>
using namespace std;
int ch[3010], n, y[3010], z[3010], c[3010][2];
long long dp[3010][3010];
vector<int> e[3010];
void dfs(int v, int p = -1) {
  ch[v] = 1;
  for (int i = 0; i < e[v].size(); i++) {
    int w = e[v][i], u = y[w] + z[w] - v;
    if (w == p) continue;
    dfs(u, w);
    ch[v] += ch[u];
  }
  if (p != -1) {
    if (y[p] == v) {
      c[p][0] = ch[v];
      c[p][1] = n - ch[v];
    } else {
      c[p][1] = ch[v];
      c[p][0] = n - ch[v];
    }
  }
}
void upd(long long &v, long long x) {
  if (v < x) v = x;
}
int val(int x, int w) {
  if (y[w] == x) return c[w][0];
  return c[w][1];
}
long long efs(int v, int pv, int u, int pu) {
  if (dp[v][u]) return dp[v][u];
  long long &r = dp[v][u];
  for (int i = 0; i < e[v].size(); i++) {
    int w = e[v][i], x = y[w] + z[w] - v;
    if (w == pv) continue;
    upd(r, efs(x, w, u, pu));
  }
  for (int i = 0; i < e[u].size(); i++) {
    int w = e[u][i], x = y[w] + z[w] - u;
    if (w == pu) continue;
    upd(r, efs(v, pv, x, w));
  }
  r += val(v, pv) * val(u, pu);
  return r;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &y[i], &z[i]);
    --y[i];
    --z[i];
    e[y[i]].push_back(i);
    e[z[i]].push_back(i);
  }
  dfs(0);
  long long ans = -1;
  for (int i = 0; i < n - 1; i++) {
    upd(ans, efs(y[i], i, z[i], i));
  }
  printf("%I64d\n", ans);
  return 0;
}
