#include <bits/stdc++.h>
using namespace std;
using big = long long;
const int N = 3020;
vector<int> adj[N];
int n;
big f[N][N], sz[N];
int fa[N];
void dfs_size(int x) {
  sz[x] = 1;
  for (int v : adj[x]) {
    if (fa[v] == -1) {
      fa[v] = x;
      dfs_size(v);
      sz[x] += sz[v];
    }
  }
}
big get_size(int x, int father) {
  if (fa[x] == father) {
    return sz[x];
  }
  return n - sz[father];
}
big dfs(int x, int x_fa, int y, int y_fa) {
  big &res = f[x][y];
  if (res != -1) {
    return res;
  }
  big w = get_size(x, x_fa) * get_size(y, y_fa);
  res = w;
  for (int vx : adj[x]) {
    if (vx != x_fa) {
      res = max(res, dfs(vx, x, y, y_fa) + w);
    }
  }
  for (int vy : adj[y]) {
    if (vy != y_fa) {
      res = max(res, dfs(x, x_fa, vy, y) + w);
    }
  }
  return res;
}
big solve() {
  memset(fa, -1, sizeof(fa));
  memset(f, -1, sizeof(f));
  fa[1] = 0;
  dfs_size(1);
  big res = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j : adj[i]) {
      if (fa[j] == i) {
        res = max(res, dfs(i, j, j, i));
      }
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  cout << solve() << endl;
}
