#include <bits/stdc++.h>
using namespace std;
const int maxn = 310;
const int mod = 1e9 + 7;
long long C[maxn][maxn], Fact[maxn];
void init() {
  C[0][0] = 1, Fact[0] = 1;
  for (int i = 1; i < maxn; i++) {
    C[i][0] = 1, Fact[i] = Fact[i - 1] * i % mod;
    for (int j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
}
long long num[maxn], emp[maxn], dp[maxn][maxn];
int main() {
  init();
  int n;
  scanf("%d", &n);
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    long long tmp;
    scanf("%lld", &tmp);
    int key = 1;
    for (int j = 1; j <= tot; j++) {
      long long x = (sqrt(tmp * emp[j]) + 0.5);
      if (x * x == tmp * emp[j]) key = 0, num[j]++;
    }
    if (key) ++tot, num[tot] = 1, emp[tot] = tmp;
  }
  dp[0][0] = 1;
  int m = 0;
  for (int i = 1; i <= tot; i++) {
    for (int j = 0; j <= n - 1 && j <= m + 1; j++) {
      if (dp[i - 1][j] == 0) continue;
      for (int k = 1; k <= num[i]; k++) {
        long long tmp = dp[i - 1][j] * C[num[i] - 1][k - 1] % mod;
        for (int p = 0; p <= k && p <= j + num[i] - k; p++) {
          long long temp = tmp * C[j][p] % mod;
          dp[i][j + num[i] - k - p] =
              (dp[i][j + num[i] - k - p] + temp * C[m + 1 - j][k - p] % mod) %
              mod;
        }
      }
    }
    m += num[i];
  }
  long long ans = dp[tot][0];
  for (int i = 1; i <= tot; i++) ans = ans * Fact[num[i]] % mod;
  printf("%lld\n", ans);
  return 0;
}
