#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1LL;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
inline long long readll() {
  long long f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1LL;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
template <class T>
inline void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void chmin(T &a, T b) {
  if (a > b) a = b;
}
inline void swap(int &a, int &b) {
  int c = a;
  a = b;
  b = c;
}
using namespace std;
const int N = 3e3 + 10;
struct node {
  int next, to;
} e[N << 1];
int head[N], cnt;
inline void add(int u, int v) {
  e[cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt++;
}
int n;
int sz[N][N], par[N][N];
inline void dfs(int x, int f, int t) {
  sz[t][x] = 1;
  par[t][x] = f;
  for (int i = head[x]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (v == f) continue;
    dfs(v, x, t);
    sz[t][x] += sz[t][v];
  }
}
long long dp[N][N];
inline long long g(int u, int v) {
  if (u == v) return 0;
  if (dp[u][v]) {
    return dp[u][v];
  }
  dp[u][v] = max(g(par[u][v], u) + sz[v][u] * sz[u][v],
                 g(par[v][u], v) + sz[v][u] * sz[u][v]);
  return dp[u][v];
}
int main() {
  memset(head, -1, sizeof(head));
  n = read();
  for (int i = (1); i <= (n - 1); ++i) {
    int u = read(), v = read();
    add(u, v);
    add(v, u);
  }
  for (int i = (1); i <= (n); ++i) {
    dfs(i, 0, i);
  }
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (n); ++j)
      if (i != j) g(i, j);
  long long ans = 0;
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (n); ++j) chmax(ans, dp[i][j]);
  printf("%lld\n", ans);
  return 0;
}
