#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) {
  return os << '(' << pai.first << ' ' << pai.second << ')';
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
  cout << '[';
  for (auto p : v) cout << p << ",";
  cout << "]";
  return os;
}
template <typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
  cout << "{";
  for (auto p : v) cout << p << ",";
  cout << "}";
  return os;
}
template <typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
  cout << "{";
  for (auto p : v) cout << p << ",";
  cout << "}";
  return os;
}
template <typename T>
void get_max(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void get_min(T &a, T b) {
  a = min(a, b);
}
const int MAXN = 3010 + 10;
int N;
vector<int> ADJ[MAXN];
int P[MAXN][MAXN];
long long dist[MAXN][MAXN];
long long D[MAXN][MAXN];
long long S[MAXN][MAXN];
vector<pair<int, int> > V[MAXN];
void dfs(int rt, int here, int par, int d) {
  P[rt][here] = par;
  S[rt][here] = 1;
  dist[rt][here] = d;
  V[dist[rt][here]].push_back(pair<int, int>(rt, here));
  for (auto there : ADJ[here])
    if (there != par) {
      dfs(rt, there, here, d + 1);
      S[rt][here] += S[rt][there];
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> N;
  for (int i = 1; i <= N - 1; i++) {
    int x, y;
    cin >> x >> y;
    ADJ[x].push_back(y);
    ADJ[y].push_back(x);
  }
  for (int i = 1; i <= N; i++) dfs(i, i, 0, 0);
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    for (auto val : V[i]) {
      int x = val.first, y = val.second;
      D[x][y] += S[y][x] * S[x][y];
      ans = max(ans, D[x][y]);
      for (int nx : ADJ[x])
        if (P[y][x] != nx) D[nx][y] = max(D[nx][y], D[x][y]);
      for (int ny : ADJ[y])
        if (P[x][y] != ny) D[x][ny] = max(D[x][ny], D[x][y]);
    }
  }
  cout << ans << '\n';
  return 0;
}
