#include <bits/stdc++.h>
const uint32_t MAX_N = 3006;
struct Vertex;
struct Path {
  uint32_t u, v;
};
std::vector<std::vector<Path>> pathsByLen;
std::vector<std::vector<uint32_t>> nextV;
struct Vertex {
  std::vector<Vertex *> edges;
  Vertex *par;
  uint32_t i;
  uint32_t depth;
  uint32_t subTree;
  Vertex() : par(nullptr), depth(0) {}
  void calc_paths_root(uint32_t r) {
    subTree = 1;
    if (i == r) {
      depth = 0;
      par = nullptr;
    } else {
      pathsByLen[depth].push_back({i, r});
      nextV[i][r] = par->i;
    }
    for (Vertex *v : edges) {
      if (v == par) {
        continue;
      }
      v->par = this;
      v->depth = depth + 1;
      v->calc_paths_root(r);
      subTree += v->subTree;
    }
  }
};
std::vector<Vertex> tree;
uint32_t n;
void input() {
  std::cin >> n;
  tree.resize(n);
  for (uint32_t i = 0; i < n; i++) {
    tree[i].i = i;
  }
  for (uint32_t i = 1; i < n; i++) {
    uint32_t u, v;
    std::cin >> u >> v;
    u--;
    v--;
    tree[u].edges.push_back(&tree[v]);
    tree[v].edges.push_back(&tree[u]);
  }
}
void precalc() {
  pathsByLen.resize(n);
  nextV.resize(n);
  for (uint32_t i = 0; i < n; i++) {
    nextV[i].resize(n);
  }
  for (uint32_t i = 0; i < n; i++) {
    tree[i].calc_paths_root(i);
  }
}
uint64_t count_paths(uint32_t u, uint32_t v) {
  uint64_t s1, s2;
  if (tree[u].subTree < tree[nextV[u][v]].subTree) {
    s1 = tree[u].subTree;
  } else {
    s1 = n - tree[nextV[u][v]].subTree;
  }
  if (tree[v].subTree < tree[nextV[v][u]].subTree) {
    s2 = tree[v].subTree;
  } else {
    s2 = n - tree[nextV[v][u]].subTree;
  }
  uint64_t ans = s1 * s2;
  return s1 * s2;
}
std::vector<std::vector<uint64_t>> dp;
uint64_t calc_dp() {
  dp.resize(n);
  for (uint32_t i = 0; i < n; i++) {
    dp[i] = std::vector<uint64_t>(n, 0);
    dp[i][i] = 0;
  }
  uint64_t ans = 0;
  for (uint32_t l = 1; l < n; l++) {
    for (Path p : pathsByLen[l]) {
      uint32_t u = p.u;
      uint32_t v = p.v;
      uint64_t prevDp = std::max(dp[nextV[u][v]][v], dp[u][nextV[v][u]]);
      uint64_t curPaths = count_paths(u, v);
      dp[u][v] = prevDp + curPaths;
      ans = std::max(ans, dp[u][v]);
    }
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  input();
  precalc();
  std::cout << calc_dp() << "\n";
}
