#include <bits/stdc++.h>
using namespace std;
const int maxN = 211;
const int oo = 1e9 + 11;
int n, d[maxN];
bool edge[maxN][maxN];
void Visit(int u, int paru) {
  for (int v = 1; v <= n; v++)
    if ((edge[u][v]) && v != paru) {
      d[v] = d[u] + 1;
      Visit(v, u);
    }
}
int Longest_Path(int x) {
  memset(d, 0, sizeof(d));
  Visit(x, x);
  int maxx = 0, node_max = 0;
  for (int i = 1; i <= n; i++)
    if (maxx < d[i]) {
      maxx = d[i];
      node_max = i;
    }
  if (node_max == 0) return 0;
  memset(d, 0, sizeof(d));
  Visit(node_max, node_max);
  maxx = 0;
  for (int i = 1; i <= n; i++)
    if (maxx < d[i]) maxx = d[i];
  return maxx;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    edge[u][v] = edge[v][u] = true;
  }
  int res = 0;
  for (int i = 1; i <= n - 1; i++)
    for (int j = i + 1; j <= n; j++)
      if (edge[i][j]) {
        edge[i][j] = edge[j][i] = false;
        res = max(res, Longest_Path(i) * Longest_Path(j));
        edge[i][j] = edge[j][i] = true;
      }
  cout << res;
  return 0;
}
