#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long z = 1;
int c[305][305], fac[305], sum[305], a[305], v[305], f[305][305], tot, sz;
int pd(int a, int b) {
  long long c = z * a * b, j;
  j = sqrt(c);
  return j * j == c;
}
int main() {
  int i, j, k, l, n, m;
  for (i = 0; i <= 300; i++) {
    c[i][0] = 1;
    for (j = 1; j <= i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
  }
  for (fac[0] = i = 1; i <= 300; i++) fac[i] = z * fac[i - 1] * i % mod;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    if (v[i]) continue;
    sum[++tot] = 1;
    v[i] = 1;
    for (j = i + 1; j <= n; j++) {
      if (pd(a[i], a[j])) v[j] = 1, sum[tot]++;
    }
  }
  f[0][0] = 1;
  for (i = 1; i <= tot; i++) {
    for (j = 0; j <= n; j++) {
      for (k = 1; k <= sum[i]; k++) {
        for (l = 0; l <= k; l++) {
          if (j + sum[i] - k - l >= 0) {
            f[i][j + sum[i] - k - l] =
                (f[i][j + sum[i] - k - l] +
                 z * f[i - 1][j] * fac[sum[i]] % mod * c[sum[i] - 1][k - 1] %
                     mod * c[j][l] % mod * c[sz + 1 - j][k - l]) %
                mod;
          }
        }
      }
    }
    sz += sum[i];
  }
  printf("%d", f[tot][0]);
  return 0;
}
