#include <bits/stdc++.h>
using namespace std;
int ar[202][202];
int visited[202];
int c;
int n;
int dfs(int x, int y) {
  int mx1 = 0, mx2 = 0, mx = 0;
  for (int i = 1; i <= n; i++) {
    if (ar[x][i] && i != y) {
      mx = max(mx, dfs(i, x));
      if (c > mx1)
        mx2 = mx1, mx1 = c;
      else if (c > mx2)
        mx2 = c;
    }
  }
  mx = max(mx, mx1 + mx2);
  c = mx1 + 1;
  return (mx);
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    ar[a][b] = 1;
    ar[b][a] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int l = 0, k = 0;
      if (ar[i][j]) {
        l = dfs(i, j);
        k = dfs(j, i);
        ans = max(ans, l * k);
      }
    }
  cout << ans;
}
