#include <bits/stdc++.h>
using namespace std;
int n, a, b, sum, f, s;
vector<int> path[202], p, q;
vector<pair<int, int> > ma;
int dfs(int x, int f, int p) {
  if (x == p) return 0;
  if (path[x].size() == 1 && path[x][0] == f) return 1;
  int mm = -1;
  for (int i = 0; i < path[x].size(); i++)
    if (path[x][i] != f) {
      mm = ((mm) > (dfs(path[x][i], x, p)) ? (mm) : (dfs(path[x][i], x, p)));
    }
  return mm + 1;
}
void add(int x, int f) {
  if (path[x].size() == 1 && path[x][0] == f) {
    q.push_back(x);
    return;
  }
  for (int i = 0; i < path[x].size(); i++)
    if (path[x][i] != f) add(path[x][i], x);
}
void cal() {
  int aa, bb, aaa, bbb;
  for (int i = 0; i < ma.size(); i++) {
    aaa = 0;
    bbb = 0;
    f = ma[i].first;
    s = ma[i].second;
    q.clear();
    q.push_back(f);
    add(f, s);
    for (int k = 0; k < q.size(); k++) {
      p.clear();
      aa = 0;
      for (int j = 0; j < path[q[k]].size(); j++)
        if (path[q[k]][j] != s) {
          p.push_back(dfs(path[q[k]][j], q[k], s));
        }
      if (p.size() == 1)
        aa = p[0];
      else if (p.size() > 1) {
        sort(p.begin(), p.end());
        aa = p[p.size() - 1] + p[p.size() - 2];
      }
      aaa = ((aa) > (aaa) ? (aa) : (aaa));
    }
    q.clear();
    q.push_back(s);
    add(s, f);
    for (int k = 0; k < q.size(); k++) {
      p.clear();
      bb = 0;
      for (int j = 0; j < path[q[k]].size(); j++)
        if (path[q[k]][j] != s) {
          p.push_back(dfs(path[q[k]][j], q[k], f));
        }
      if (p.size() == 1)
        bb = p[0];
      else if (p.size() > 1) {
        sort(p.begin(), p.end());
        bb = p[p.size() - 1] + p[p.size() - 2];
      }
      bbb = ((bb) > (bbb) ? (bb) : (bbb));
    }
    sum = ((sum) > ((aaa) * (bbb)) ? (sum) : ((aaa) * (bbb)));
  }
  printf("%d\n", sum);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &a, &b);
    ma.push_back(make_pair(a, b));
    path[a].push_back(b);
    path[b].push_back(a);
  }
  cal();
}
