#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 62;
const int mods = 1e9 + 7;
const int MAXN = 1000005;
const int INF = 0x3f3f3f3f;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
vector<int> e[3005];
int fa[3005][3005];
long long sz[3005][3005], f[3005][3005];
void dfs(int rt, int x, int father) {
  sz[rt][x] = 1, fa[rt][x] = father;
  for (auto v : e[x]) {
    if (v == father) continue;
    dfs(rt, v, x), sz[rt][x] += sz[rt][v];
  }
}
long long getans(int x, int y) {
  if (x == y) return 0;
  if (f[x][y]) return f[x][y];
  return f[x][y] = max(getans(fa[y][x], y), getans(x, fa[x][y])) +
                   sz[x][y] * sz[y][x];
}
signed main() {
  int n = read();
  for (int i = 1, u, v; i < n; i++)
    u = read(), v = read(), e[u].push_back(v), e[v].push_back(u);
  for (int i = 1; i <= n; i++) dfs(i, i, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) upmax(ans, getans(i, j));
  printf("%lld\n", ans);
  return 0;
}
