#include <bits/stdc++.h>
using namespace std;
const int oo = 0x7fffffff;
const long long OO = 1000000000000000000LL;
const int base = 1000000007;
const int dx[] = {1, 0, 0, -1};
const int dy[] = {0, 1, -1, 0};
int n, d[222];
vector<int> adj[222];
pair<int, int> edge[222];
void dfs(int u, int current, int never) {
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v == current || v == never) continue;
    d[v] = d[u] + 1;
    dfs(v, u, never);
  }
}
int main() {
  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);
    edge[i] = make_pair(u, v);
  }
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    int result = 0;
    memset(d, 0, sizeof d);
    dfs(edge[i].first, edge[i].first, edge[i].second);
    int starter = 0;
    for (int j = 1; j <= n; ++j)
      if (d[starter] < d[j]) starter = j;
    memset(d, 0, sizeof d);
    dfs(starter, starter, edge[i].second);
    for (int j = 1; j <= n; ++j) result = max(result, d[j]);
    memset(d, 0, sizeof d);
    dfs(edge[i].second, edge[i].second, edge[i].first);
    starter = 0;
    for (int j = 1; j <= n; ++j)
      if (d[starter] < d[j]) starter = j;
    memset(d, 0, sizeof d);
    dfs(starter, starter, edge[i].first);
    int tmp = 0;
    for (int j = 1; j <= n; ++j) tmp = max(tmp, d[j]);
    result *= tmp;
    ans = max(ans, result);
  }
  cout << ans << endl;
  return 0;
}
