#include <bits/stdc++.h>
using namespace std;
bool vt[202][202];
int cnt, n;
int dfs(int x, int y) {
  int mx1 = 0, mx2 = 0, mx = 0;
  for (int i = 1; i <= n; i++)
    if (vt[x][i] && i != y) {
      mx = max(mx, dfs(i, x));
      if (cnt > mx1)
        mx2 = mx1, mx1 = cnt;
      else if (cnt > mx2)
        mx2 = cnt;
    }
  mx = max(mx, mx1 + mx2);
  cnt = mx1 + 1;
  return mx;
}
int main() {
  ios::sync_with_stdio(0);
  int x, y, m, sm = 0;
  cin >> n;
  for (int i = 0; i < n - 1; i++) cin >> x >> y, vt[x][y] = 1, vt[y][x] = 1;
  int mx = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int l = 0, k = 0;
      if (vt[i][j]) {
        l = dfs(i, j);
        k = dfs(j, i);
        mx = max(mx, l * k);
      }
    }
  cout << mx;
}
