#include <bits/stdc++.h>
using namespace std;
const int maxN = 300 + 10;
vector<pair<int, int> > E;
bool mark[maxN];
int _dist[maxN];
vector<int> adj[maxN];
void eraseit(pair<int, int> x) {
  int p1 = x.first, p2 = x.second;
  for (int i = 0; i < adj[p1].size(); i++) {
    if (adj[p1][i] == p2) {
      adj[p1].erase(adj[p1].begin() + i);
      break;
    }
  }
  for (int i = 0; i < adj[p2].size(); i++) {
    if (adj[p2][i] == p1) {
      adj[p2].erase(adj[p2].begin() + i);
      break;
    }
  }
}
void insertit(pair<int, int> x) {
  adj[x.first].push_back(x.second);
  adj[x.second].push_back(x.first);
}
void DFS(int x) {
  mark[x] = true;
  for (int i = 0; i < adj[x].size(); i++) {
    int t = adj[x][i];
    if (!mark[t]) {
      _dist[t] = _dist[x] + 1;
      DFS(t);
    }
  }
}
int call(int p1) {
  memset(mark, 0, sizeof mark);
  _dist[p1] = 0;
  DFS(p1);
  int idx = 0, val = 0;
  for (int i = 0; i < maxN; i++) {
    if (mark[i] && _dist[i] >= val) {
      val = _dist[i];
      idx = i;
    }
  }
  memset(mark, 0, sizeof mark);
  _dist[idx] = 0;
  DFS(idx);
  int res = 0;
  for (int i = 0; i < maxN; i++) {
    if (mark[i]) res = max(res, _dist[i]);
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    E.push_back(make_pair(a, b));
  }
  int ans = 0;
  for (int i = 0; i < E.size(); i++) {
    eraseit(E[i]);
    ans = max(ans, call(E[i].first) * call(E[i].second));
    insertit(E[i]);
  }
  cout << ans << endl;
}
