#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
using ll = long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int length[3001][3001];
int lin[3001][3001];
int rin[3001][3001];
ll ans[3001][3001];
int dis;
int u;
vector<int> adj[3001];
vector<int> cur;
void dfs(int v) {
  dis++;
  if (dis >= 2) {
    lin[u][v] = cur[1];
    rin[u][v] = cur.back();
  }
  cur.push_back(v);
  length[u][v] = dis;
  for (auto w : adj[v]) {
    if (length[u][w] == int(1e9)) dfs(w);
  }
  dis--;
  cur.pop_back();
}
bool cmp(pair<int, int> A, pair<int, int> B) {
  if (length[A.first][A.second] != length[B.first][B.second])
    return length[A.first][A.second] < length[B.first][B.second];
  if (A.first != B.first) return A.first < B.first;
  return A.second < B.second;
}
int depth[3001];
int vis[3001];
int cnt[3001];
void dfs2(int v) {
  vis[v] = 1;
  for (auto u : adj[v]) {
    if (!vis[u]) {
      depth[u] = depth[v] + 1;
      dfs2(u);
      cnt[v] += cnt[u];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      length[i][j] = int(1e9);
      ans[i][j] = -int(1e9);
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  u = 1;
  for (; u <= n; u++) {
    cnt[u] = 1;
    dis = -1;
    dfs(u);
  }
  for (int i = 1; i <= n; i++) {
  }
  depth[1] = 1;
  dfs2(1);
  for (int v = 1; v <= n; v++) {
  }
  vector<pair<int, int>> V;
  for (int i = 1; i <= n; i++) {
    for (auto j : adj[i]) {
      if (depth[j] > depth[i]) {
        ans[i][j] = cnt[j] * (n - cnt[j]);
        ans[j][i] = ans[i][j];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (length[i][j] >= 2 && length[i][j] < int(1e9)) {
        V.push_back({i, j});
      }
    }
  }
  sort((V).begin(), (V).end(), cmp);
  ll gans = 1;
  for (int i = 0; i < int((V).size()); i++) {
    int a = V[i].first;
    int b = V[i].second;
    int ain = lin[a][b];
    int bin = rin[a][b];
    int lhs = 0;
    int rhs = 0;
    if (depth[a] > depth[ain])
      lhs = cnt[a];
    else
      lhs = n - cnt[ain];
    if (depth[b] > depth[bin])
      rhs = cnt[b];
    else
      rhs = n - cnt[bin];
    ans[a][b] = max(lhs * rhs + ans[ain][b], lhs * rhs + ans[a][bin]);
    ans[b][a] = ans[a][b];
    gans = max(gans, ans[a][b]);
  }
  cout << gans << endl;
}
