#include <bits/stdc++.h>
using namespace std;
int head[201], en, src, des, n, D, pre[201];
struct edge {
  int v, next;
} e[201 << 1];
void Add(const int& u, const int& v) {
  e[en].v = v, e[en].next = head[u], head[u] = en++;
  e[en].v = u, e[en].next = head[v], head[v] = en++;
}
int arr[201], k, isDone, maxLen[201], maxPath[201], g_maxLen, ans;
void Solve() {
  int u, v, fa, pre = 0, mLen1 = 0, mLen2 = 0, mPath = 0, t;
  for (int j = k; j >= 1; --j) {
    u = arr[j], fa = arr[j - 1];
    for (int i = head[u]; i != -1; i = e[i].next) {
      if ((v = e[i].v) == fa || v == pre) continue;
      if (maxLen[v] >= mLen1) {
        mLen2 = mLen1, mLen1 = maxLen[v];
      } else if (maxLen[v] > mLen2)
        mLen2 = maxLen[v];
      if (maxPath[v] > g_maxLen) g_maxLen = maxPath[v];
    }
    mPath = max(mPath, mLen1 + mLen2 + 1);
    t = (mPath - 1) * (maxPath[fa] - 1);
    if (t > ans) ans = t;
    pre = u, mLen2 = 0, ++mLen1;
  }
}
void DFS(const int& u, const int& fa, int d, int& s) {
  if (d > D) D = d, s = u;
  int mLen1 = 0, mLen2 = 0;
  for (int i = head[u], v; i != -1; i = e[i].next) {
    if ((v = e[i].v) == fa) continue;
    DFS(v, u, d + 1, s);
    if (isDone) {
      pre[e[i].v] = u;
      if (maxPath[v] > maxPath[u]) maxPath[u] = maxPath[v];
      if (maxLen[v] >= mLen1) {
        mLen2 = mLen1, mLen1 = maxLen[v];
      } else if (maxLen[v] > mLen2)
        mLen2 = maxLen[v];
    }
  }
  if (isDone) {
    maxLen[u] = mLen1 + 1;
    maxPath[u] = max(maxPath[u], mLen1 + mLen2 + 1);
  }
}
int main() {
  int u, v;
  while (scanf("%d", &n) != EOF) {
    memset(head, -1, sizeof(int) * (n + 1));
    memset(maxLen, 0, sizeof(int) * (n + 1));
    memset(maxPath, 0, sizeof(int) * (n + 1));
    en = 0, k = 0, isDone = false, g_maxLen = 0, ans = 0;
    for (int i = 1; i < n; ++i) {
      scanf("%d%d", &u, &v);
      Add(u, v);
    }
    D = 0;
    DFS(1, 0, 0, src);
    D = 0, isDone = true, pre[src] = 0;
    DFS(src, 0, 0, des);
    int t = des;
    do {
      arr[++k] = t;
    } while ((t = pre[t]));
    Solve();
    printf("%d\n", max(ans, (g_maxLen - 1) * (k - 1)));
  }
  return 0;
}
