#include <bits/stdc++.h>
using namespace std;
const int maxn = 220;
bool vis[maxn];
vector<int> G[maxn];
int ans;
int dfs(int v, int x) {
  int sum = 0;
  int max1 = 0, max2 = 0;
  for (int i = 0; i < G[v].size(); i++) {
    if (G[v][i] != x) {
      sum = max(sum, dfs(G[v][i], v));
      if (ans > max1) {
        max2 = max1;
        max1 = ans;
      } else
        max2 = ans > max2 ? ans : max2;
    }
  }
  sum = max(sum, max1 + max2);
  ans = max1 + 1;
  return sum;
}
int main() {
  int n, a, b;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i <= n; i++) G[i].clear();
    for (int i = 0; i < n - 1; i++) {
      scanf("%d%d", &a, &b);
      G[a].push_back(b);
      G[b].push_back(a);
    }
    int last_ans = 0;
    for (int i = 0; i < n; i++) {
      int num = G[i].size(), temp;
      for (int j = 0; j < num; j++) {
        int ans = 0;
        temp = dfs(i, G[i][j]) * dfs(G[i][j], i);
        last_ans = max(last_ans, temp);
      }
    }
    printf("%d\n", last_ans);
  }
  return 0;
}
