#include <bits/stdc++.h>
using namespace std;
inline long long next_int() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const long long maxn = 305 + 10;
long long v[maxn], u[maxn], res, max_h, end_point;
vector<long long> g[maxn];
long long X;
inline void dfs(long long node, long long fa = -1, long long h = 0) {
  if (h > max_h) max_h = h, end_point = node;
  for (auto u : g[node])
    if (u - fa && u != X) dfs(u, node, h + 1);
}
inline long long get_maxi(long long source, long long block) {
  max_h = 0;
  X = block;
  end_point = source;
  dfs(source, block);
  max_h = 0;
  dfs(end_point);
  return max_h;
}
int32_t main() {
  long long n = next_int();
  for (long long i = 0; i < n - 1; i++) {
    v[i] = next_int() - 1, u[i] = next_int() - 1;
    g[v[i]].push_back(u[i]), g[u[i]].push_back(v[i]);
  }
  for (long long i = 0; i < n - 1; i++) {
    res = max(res, get_maxi(v[i], u[i]) * get_maxi(u[i], v[i]));
  }
  cout << res << endl;
}
