#include <bits/stdc++.h>
using namespace std;
int n, cnt;
int head[10010];
int root;
long long p[3030][3030], s[3030][3030], f[3030][3030];
struct edge {
  int to, next;
};
edge edges[10010];
void addedge(int u, int v) {
  edges[cnt].to = v;
  edges[cnt].next = head[u];
  head[u] = cnt++;
}
void build(int u, int fa) {
  s[root][u] = 1;
  for (int i = head[u]; i != -1; i = edges[i].next) {
    int v = edges[i].to;
    if (v == fa) continue;
    p[root][v] = u;
    build(v, u);
    s[root][u] += s[root][v];
  }
}
long long dp(int u, int v) {
  if (u == v) return 0;
  if (f[u][v]) return f[u][v];
  return f[u][v] = max(dp(u, p[u][v]), dp(v, p[v][u])) + s[u][v] * s[v][u];
}
void init() {
  for (int i = 0; i <= n; i++) {
    head[i] = -1;
  }
}
long long max(long long a, long long b) { return a > b ? a : b; }
int main() {
  cin >> n;
  init();
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  long long ans = 0;
  for (root = 1; root <= n; root++) {
    build(root, -1);
  }
  for (int u = 1; u <= n; u++) {
    for (int v = 1; v <= n; v++) {
      ans = max(ans, dp(u, v));
    }
  }
  cout << ans << endl;
  return 0;
}
