#include <bits/stdc++.h>
using namespace std;
struct ii {
  ii(int one, int two) : one(one), two(two) {}
  int one, two;
};
const int maxn = 200;
int n, cnt;
int a[maxn][maxn];
vector<pair<int, int> > e;
bool v[maxn];
ii dfs(int x, int level = 1) {
  v[x] = 1;
  int first = 0;
  int second = 0;
  int best = 0;
  for (int i = 0; i < n; i++)
    if (a[x][i] && !v[i]) {
      ii s = dfs(i, level + 1);
      if (s.one + 1 > second) {
        second = s.one + 1;
        if (second > first) swap(first, second);
      }
      best = max(best, s.two);
    }
  v[x] = 0;
  return ii(first, max(best, first + second));
}
int main() {
  scanf("%i", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%i%i", &u, &v);
    u--;
    v--;
    a[u][v] = 1;
    a[v][u] = 1;
    e.push_back(pair<int, int>(u, v));
  }
  for (vector<pair<int, int> >::iterator end = e.end(), i = e.begin(); i != end;
       i++) {
    pair<int, int>& j = *i;
    a[j.first][j.second] = 0;
    a[j.second][j.first] = 0;
    cnt = max(cnt, dfs(j.first).two * dfs(j.second).two);
    a[j.first][j.second] = 1;
    a[j.second][j.first] = 1;
  }
  printf("%i\n", cnt);
}
