#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <class T>
T Abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return R;
}
struct data {
  int to, active;
  data(int a, int b) {
    to = a;
    active = b;
  }
};
vector<data> v[250];
int dist[250], col[250], n;
int dfs(int source) {
  col[source] = 1;
  for (int i = 0; i < (int)v[source].size(); i++) {
    if (!v[source][i].active) continue;
    int to = v[source][i].to;
    if (!col[to]) {
      dist[to] = dist[source] + 1;
      dfs(to);
    }
  }
  return 0;
}
int get_longest_path(int source) {
  memset(col, 0, sizeof col);
  memset(dist, 0, sizeof dist);
  dfs(source);
  int dst = 0, longest_node = source;
  for (int i = 1; i <= n; i++)
    if (dist[i] > dst) dst = dist[i], longest_node = i;
  memset(col, 0, sizeof col);
  memset(dist, 0, sizeof dist);
  dfs(longest_node);
  dst = 0;
  for (int i = 1; i <= n; i++) dst = max(dst, dist[i]);
  return dst;
}
int main() {
  int a, b;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &a, &b);
    v[a].push_back(data(b, 1));
    v[b].push_back(data(a, 1));
  }
  long long best = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (int)v[i].size(); j++) {
      int node1 = i, node2 = v[i][j].to;
      v[i][j].active = 0;
      int indx;
      for (int p = 0; p < (int)v[node2].size(); p++)
        if (v[node2][p].to == node1) v[node2][p].active = 0, indx = p;
      best = max(best, (long long)get_longest_path(node1) *
                           (long long)get_longest_path(node2));
      v[i][j].active = 1;
      v[node2][indx].active = 1;
    }
  }
  cout << best << endl;
  return 0;
}
