#include <bits/stdc++.h>
const double inf = 1e20;
using namespace std;
int tre[222][222], n, d[222], maxn;
pair<int, int> xy[222];
int dfs(int p, int pp) {
  int ans = pp;
  for (int i = 1; i <= n; i++)
    if (tre[pp][i] && i != p) {
      d[i] = d[pp] + 1;
      int u = dfs(pp, i);
      if (d[ans] < d[u]) ans = u;
    }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    xy[i].first = x;
    xy[i].second = y;
    tre[x][y] = 1;
    tre[y][x] = 1;
  }
  for (int i = 1; i < n; i++) {
    memset(d, 0, sizeof(d));
    tre[xy[i].first][xy[i].second] = 0;
    tre[xy[i].second][xy[i].first] = 0;
    int u = dfs(0, xy[i].first);
    d[u] = 0;
    int ansx = d[dfs(0, u)];
    memset(d, 0, sizeof(d));
    u = dfs(0, xy[i].second);
    d[u] = 0;
    ansx *= d[dfs(0, u)];
    if (ansx > maxn) maxn = ansx;
    tre[xy[i].first][xy[i].second] = 1;
    tre[xy[i].second][xy[i].first] = 1;
  }
  cout << maxn;
  return 0;
}
