#include <bits/stdc++.h>
using namespace std;
const int cap = 201;
vector<int> graph[cap];
vector<bool> pre(cap);
map<int, int> cnt[cap];
int max_len[cap];
int res = 0;
void get_res(int i, int len, int root, int idx, bool outer) {
  ++len;
  pre[i] = true;
  if (max_len[i]) {
    --cnt[root][max_len[i]];
    if (!cnt[root][max_len[i]]) cnt[root].erase(max_len[i]);
  }
  if (outer) {
    for (size_t j = idx + 1; j < graph[root].size(); ++j) {
      int k = graph[root][j];
      if (!pre[k]) get_res(k, len, root, j, false);
    }
    for (size_t j = 0; j < graph[i].size(); ++j) {
      int k = graph[i][j];
      if (!pre[k]) get_res(k, len, root, idx, true);
    }
  }
  if (!cnt[root].empty()) {
    res = max(res, cnt[root].rbegin()->first * len);
    if (!outer)
      for (int j : graph[i])
        if (!pre[j]) get_res(j, len, root, idx, false);
  }
  pre[i] = false;
  if (max_len[i]) ++cnt[root][max_len[i]];
}
int get_len(int i) {
  pre[i] = true;
  multiset<int> ms;
  cnt[i].clear();
  for (int j : graph[i]) {
    if (pre[j]) continue;
    ms.insert(get_len(j));
    for (auto it = cnt[j].begin(); it != cnt[j].end(); ++it)
      cnt[i][it->first] += it->second;
    if (max_len[j]) ++cnt[i][max_len[j]];
  }
  for (size_t j = 0; j < graph[i].size(); ++j) {
    int k = graph[i][j];
    if (pre[k]) continue;
    get_res(k, 0, i, j, true);
  }
  pre[i] = false;
  max_len[i] = 0;
  int ans = 1;
  for (int k = 0; k < 2 && !ms.empty(); ++k, ms.erase(prev(ms.end()))) {
    ans = max(ans, *ms.rbegin() + 1);
    max_len[i] += *ms.rbegin();
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  int a, b;
  for (int i = 1; i < n; ++i) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  get_len(1);
  pre[1] = true;
  cout << res;
  return 0;
}
