#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 305, Mod = 1e9 + 7;
long long C[MAX_N][MAX_N], F[MAX_N], dp[MAX_N][MAX_N], A[MAX_N];
long long siz[MAX_N];
bool used[MAX_N];
long long n, m;
void init(long long n) {
  F[0] = 1;
  for (long long i = 0; i <= n; i++) {
    if (i) F[i] = F[i - 1] * i % Mod;
    C[i][0] = 1;
    for (long long j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
  }
}
signed main() {
  init(300);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> A[i];
  for (long long i = 1; i <= n; i++) {
    if (!used[i]) {
      m++;
      for (long long j = i; j <= n; j++) {
        long long t = sqrt(A[i] * A[j]);
        if (t * t == A[i] * A[j]) {
          used[j] = true;
          siz[m]++;
        }
      }
    }
  }
  dp[1][siz[1] - 1] = 1;
  long long len = siz[1];
  for (long long i = 2; i <= m; i++) {
    for (long long j = 0; j < len; j++) {
      if (dp[i - 1][j]) {
        for (long long k = 0; k < siz[i]; k++) {
          for (long long d = 0; d <= min(j, k + 1); d++) {
            dp[i][j + siz[i] - k - d - 1] += dp[i - 1][j] * C[siz[i] - 1][k] %
                                             Mod * C[j][d] % Mod *
                                             C[len - j + 1][k - d + 1] % Mod;
            dp[i][j + siz[i] - k - d - 1] %= Mod;
          }
        }
      }
    }
    len += siz[i];
  }
  long long ans = dp[m][0];
  for (long long i = 1; i <= m; i++) ans = ans * F[siz[i]] % Mod;
  cout << ans << endl;
  return 0;
}
