#include <bits/stdc++.h>
using namespace std;
int h;
vector<int> a[200], e;
int dfs(int v, int f) {
  int mx = 0, mx1 = 0, mx2 = 0;
  for (auto u : a[v]) {
    if (u != f) {
      mx = max(mx, dfs(u, v));
      if (h > mx1) {
        mx2 = mx1;
        mx1 = h;
      } else
        mx2 = max(mx2, h);
    }
  }
  mx = max(mx, mx1 + mx2);
  h = mx1 + 1;
  return mx;
}
int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 0, x, y; i < n - 1; i++) {
    cin >> x >> y;
    a[--x].push_back(--y);
    a[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    for (auto j : a[i]) {
      int x = dfs(j, i), y = dfs(i, j);
      ans = max(ans, x * y);
    }
  }
  cout << ans;
  return 0;
}
