#include <bits/stdc++.h>
short matAdy[222][222];
int n, deep, j;
int elMayorEntre(int a, int b);
int dfs(int u, int pre);
int main() {
  int a, b, u, v, i, j, ganancia = 0;
  scanf("%d", &n);
  memset(matAdy, 0, sizeof(matAdy));
  for (i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    matAdy[u][v] = 1;
    matAdy[v][u] = 1;
  }
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      if (matAdy[i][j]) {
        a = dfs(i, j);
        b = dfs(j, i);
        ganancia = elMayorEntre(ganancia, a * b);
      }
    }
  }
  printf("%d", ganancia);
  return 0;
}
int elMayorEntre(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int dfs(int u, int pre) {
  int i, s = 0;
  int maxd1 = 0, maxd2 = 0;
  for (i = 1; i <= n; i++)
    if (matAdy[u][i] && i != pre) {
      s = elMayorEntre(dfs(i, u), s);
      if (deep > maxd1) {
        maxd2 = maxd1;
        maxd1 = deep;
      } else
        maxd2 = elMayorEntre(deep, maxd2);
    }
  s = elMayorEntre(s, maxd1 + maxd2);
  deep = maxd1 + 1;
  return s;
}
