#include <bits/stdc++.h>
using namespace std;
int ans = 0;
vector<vector<int> > v(209);
int l;
int ans1 = 0;
int ans2 = 0;
int arr[209][2];
int dfs(int nw, int pa, bool f) {
  if (nw == l) f = 1;
  for (int i = 0; i < int(v[nw].size()); i++) {
    if (v[nw][i] != pa) {
      int val = dfs(v[nw][i], nw, f);
      if (arr[nw][0] < val) {
        arr[nw][1] = arr[nw][0];
        arr[nw][0] = val;
      } else if (arr[nw][1] < val)
        arr[nw][1] = val;
      if (f == 0) {
        ans1 = max(ans1, arr[nw][0] + arr[nw][1] + 1);
      }
      if (f == 1) {
        ans2 = max(ans2, arr[nw][0] + arr[nw][1] + 1);
      }
    }
  }
  if (nw == l) return 0;
  return arr[nw][0] + 1;
}
int main() {
  int n = 0;
  cin >> n;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 2; i <= n; i++) {
    memset(arr, 0, sizeof arr);
    ans1 = 1;
    ans2 = 1;
    l = i;
    dfs(1, -1, 0);
    ans = max(ans, (ans1 - 1) * (ans2 - 1));
  }
  cout << ans << endl;
  return 0;
}
