#include <bits/stdc++.h>
using namespace std;
const int maxn = 303, mod = 1000000007;
int Plus(int x, int y) { return (x += y) >= mod ? x - mod : x; }
void Pluseq(int &x, int y) {
  if ((x += y) >= mod) x -= mod;
}
int Minus(int x, int y) { return Plus(x, mod - y); }
void Minuseq(int &x, int y) { Pluseq(x, mod - y); }
int mul(long long x, int y) { return x * y % mod; }
void muleq(int &x, int y) { x = mul(x, y); }
int qpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) muleq(ans, x);
    muleq(x, x);
    y >>= 1;
  }
  return ans;
}
int n, a[maxn], fac[maxn], ifac[maxn], f[maxn], g[maxn];
int C(int n, int m) { return mul(mul(fac[n], ifac[m]), ifac[n - m]); }
void solve(int &x) {
  int y = x, z = x;
  for (int i = 2; i * i <= y && z > 1; i++) {
    if (z % i == 0) {
      int cnt = 0;
      while (z % i == 0) {
        z /= i;
        if (!((++cnt) & 1)) x /= (i * i);
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = mul(fac[i - 1], i);
  ifac[n] = qpow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--) ifac[i] = mul(ifac[i + 1], i + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    solve(a[i]);
  }
  sort(a + 1, a + n + 1);
  f[0] = 1;
  int tot = 0;
  for (int i = 1, j = 1; i <= n; i = j) {
    for (; j <= n && a[i] == a[j]; j++)
      ;
    int m = j - i;
    tot += m - 1;
    for (int k = 0; k < m; k++) {
      int res = mul(mul(fac[m], ifac[m - k]), C(m - 1, m - k - 1));
      for (int l = 0; k + l <= tot; l++) Pluseq(g[k + l], mul(res, f[l]));
    }
    for (int k = 0; k <= tot; k++) f[k] = g[k], g[k] = 0;
  }
  int ans = 0;
  for (int i = 0; i <= tot; i++)
    (i & 1 ? Minuseq : Pluseq)(ans, mul(f[i], fac[n - i]));
  printf("%d\n", ans);
  return 0;
}
