#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> graph;
vector<vector<long long>> parent;
vector<vector<long long>> sizes;
vector<vector<long long>> cache;
void dfs(long long node, long long p, long long root) {
  parent[node][root] = p;
  for (auto child : graph[node]) {
    if (child == p) continue;
    dfs(child, node, root);
    sizes[node][root] += sizes[child][root];
  }
}
long long dp(long long u, long long v) {
  if (u == v) return 0;
  if (cache[u][v] == -1)
    cache[u][v] = sizes[u][v] * sizes[v][u] +
                  max(dp(parent[u][v], v), dp(u, parent[v][u]));
  return cache[u][v];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long n;
  cin >> n;
  graph = vector<vector<long long>>(n);
  for (long long i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    --u, --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  parent = vector<vector<long long>>(n, vector<long long>(n));
  sizes = vector<vector<long long>>(n, vector<long long>(n, 1));
  for (long long i = 0; i < n; ++i) {
    dfs(i, i, i);
  }
  cache = vector<vector<long long>>(n, vector<long long>(n, -1));
  long long res = 0;
  for (long long i = 0; i < n; ++i) {
    for (long long j = i + 1; j < n; ++j) {
      res = max(res, dp(i, j));
    }
  }
  cout << res << endl;
}
