#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> parent;
vector<vector<int>> treeSize;
vector<vector<long long>> dp;
void executeDFS(vector<vector<int>> &adjList, int root, int n) {
  stack<int> dfs;
  vector<bool> marked(n, false);
  dfs.push(root);
  parent[root][root] = root;
  while (!dfs.empty()) {
    int curNode = dfs.top();
    if (marked[curNode]) {
      int nodeSize = 1;
      for (int node : adjList[curNode]) {
        if (node != parent[root][curNode]) {
          nodeSize += treeSize[root][node];
        }
      }
      treeSize[root][curNode] = nodeSize;
      dfs.pop();
    } else {
      marked[curNode] = true;
      for (int node : adjList[curNode]) {
        if (node != parent[root][curNode]) {
          dfs.push(node);
          parent[root][node] = curNode;
        }
      }
    }
  }
}
long long getDP(int u, int v) {
  if (dp[u][v] != -1) return dp[u][v];
  long long add = max(getDP(u, parent[u][v]), getDP(parent[v][u], v));
  long long val = treeSize[u][v] * treeSize[v][u] + add;
  dp[u][v] = val;
  dp[v][u] = val;
  return val;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<vector<int>> adjList(n, vector<int>());
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adjList[u - 1].push_back(v - 1);
    adjList[v - 1].push_back(u - 1);
  }
  parent.assign(n, vector<int>(n, -1));
  treeSize.assign(n, vector<int>(n, -1));
  for (int root = 0; root < n; root++) {
    executeDFS(adjList, root, n);
  }
  dp.assign(n, vector<long long>(n, -1));
  for (int i = 0; i < n; i++) {
    dp[i][i] = 0;
  }
  long long maxVal = 0;
  for (int u = 0; u < n; u++) {
    for (int v = u + 1; v < n; v++) {
      long long candVal = getDP(u, v);
      if (candVal > maxVal) maxVal = candVal;
    }
  }
  printf("%lld\n", maxVal);
}
