#include <bits/stdc++.h>
using namespace std;
const int N = 201;
int n;
vector<int> adj[N];
int product;
int solve(int node, int parent, int forbid, int &dist) {
  if (node == forbid)
    return -1;
  else {
    int mx1 = -1, mx2 = -1;
    for (int child : adj[node]) {
      if (child == parent) continue;
      int len = solve(child, node, forbid, dist);
      if (len > mx1) {
        mx2 = mx1;
        mx1 = len;
      } else if (len > mx2) {
        mx2 = len;
      }
    }
    dist = max(dist, mx1 + mx2 + 2);
    return mx1 + 1;
  }
}
void dfs(int node, int parent) {
  for (int child : adj[node]) {
    if (child == parent) continue;
    int a = 0;
    solve(child, node, 0, a);
    int b = 0;
    solve(1, -1, child, b);
    product = max(product, a * b);
    dfs(child, node);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  product = 0;
  dfs(1, -1);
  cout << product;
}
