#include <bits/stdc++.h>
using namespace std;
vector<int> adj[202];
int height[202], best[202][3];
int N;
int getHeight(int ind, int parent) {
  if (height[ind] != -1) return height[ind];
  int ret = 1;
  for (int i = 0; i < (int)adj[ind].size(); i++) {
    if (adj[ind][i] == parent) continue;
    ret = max(ret, getHeight(adj[ind][i], ind) + 1);
  }
  return height[ind] = ret;
}
int solve(int ind, int parent, int f) {
  if (best[ind][f] != -1) return best[ind][f];
  int ret = 0;
  if (!f) {
    for (int i = 0; i < (int)adj[ind].size(); i++) {
      if (adj[ind][i] == parent) continue;
      int a = 0, b = 0;
      for (int j = 0; j < (int)adj[ind].size(); j++) {
        if (adj[ind][j] == parent || j == i) continue;
        int h = getHeight(adj[ind][j], adj[ind][j]);
        if (h > a)
          b = a, a = h;
        else if (h > b)
          b = h;
      }
      ret = max(ret, (a + b) * solve(adj[ind][i], ind, f + 1));
    }
  } else {
    int a = 0, b = 0;
    for (int j = 0; j < (int)adj[ind].size(); j++) {
      if (adj[ind][j] == parent) continue;
      int h = getHeight(adj[ind][j], adj[ind][j]);
      if (h > a)
        b = a, a = h;
      else if (h > b)
        b = h;
      ret = max(ret, solve(adj[ind][j], ind, f));
    }
    ret = max(ret, a + b);
  }
  return best[ind][f] = ret;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int ret = 0;
  for (int i = 0; i < N; i++) {
    memset(height, -1, sizeof height);
    memset(best, -1, sizeof best);
    getHeight(i, i);
    ret = max(ret, solve(i, i, 0));
  }
  printf("%d\n", ret);
}
