#include <bits/stdc++.h>
using namespace std;
int dp1[204], dp2[204], ans;
vector<int> adjlist[204];
void dfs(int node, int par) {
  vector<int> clist;
  dp2[node] = 0;
  for (auto i : adjlist[node]) {
    if (i != par) {
      clist.push_back(i);
    }
  }
  multiset<int> dp2s;
  for (auto j : clist) {
    dfs(j, node);
    dp1[node] = max(dp1[node], dp1[j] + 1);
    dp2[node] = max(dp2[node], dp2[j]);
    dp2s.insert(dp2[j]);
  }
  dp2[node] = max(dp1[node], dp2[node]);
  for (int i = 0; i < (int)clist.size(); ++i) {
    for (int j = i + 1; j < (int)clist.size(); ++j) {
      dp2[node] = max(dp1[clist[i]] + dp1[clist[j]] + 2, dp2[node]);
      ans = max(ans, (dp1[clist[i]] + 1) * dp1[clist[j]]);
      ans = max(ans, (dp1[clist[j]] + 1) * dp1[clist[i]]);
      ans = max(ans, dp2[clist[i]] * dp2[clist[j]]);
      dp2s.erase(dp2s.find(dp2[clist[i]]));
      dp2s.erase(dp2s.find(dp2[clist[j]]));
      if ((int)dp2s.size())
        ans = max(ans, (dp1[clist[i]] + dp1[clist[j]] + 2) * (*dp2s.rbegin()));
      dp2s.insert(dp2[clist[i]]);
      dp2s.insert(dp2[clist[j]]);
    }
  }
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    adjlist[u].push_back(v);
    adjlist[v].push_back(u);
  }
  for (int i = 1; i < n + 1; ++i) {
    memset(dp1, 0, sizeof dp1);
    memset(dp2, 0, sizeof dp2);
    dfs(i, 0);
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
