#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
int a[305], f[305];
int sz[305], cnt, ins[305];
int ff(int x) { return x == f[x] ? x : f[x] = ff(f[x]); }
int dp[305][305];
int fac[305], inv[305];
void initfac(int n) {
  fac[0] = inv[0] = 1;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    fac[i] = (long long)fac[i - 1] * i % 1000000007;
    inv[i] = fastPow(fac[i], 1000000007 - 2);
  }
}
int C(int n, int m) {
  if (n < m) return 0;
  return (long long)fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
void fmain(int tid) {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", a + i);
  for (int(i) = 1; (i) <= (int)(n); (i)++) f[i] = i;
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    for (int j = i + 1; j <= n; j++) {
      long long g = (long long)a[i] * a[j];
      long long gg = sqrt(g);
      if (gg * gg == g) {
        int fx = ff(i), fy = ff(j);
        if (fx == fy) continue;
        f[fx] = fy;
      }
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    int fx = ff(i);
    if (ins[fx] == 0) ins[fx] = ++cnt;
    sz[ins[fx]]++;
  }
  int ps = 0;
  dp[0][0] = 1;
  initfac(305 - 1);
  for (int(i) = 1; (i) <= (int)(cnt); (i)++) {
    for (int j = 0; j <= ps; j++)
      if (dp[i - 1][j]) {
        for (int q = 1; q <= sz[i]; q++) {
          for (int p = 0; p <= min(q, j); p++) {
            int k = j - p + sz[i] - q;
            addmod(dp[i][k], (long long)dp[i - 1][j] * fac[sz[i]] % 1000000007 *
                                 C(sz[i] - 1, q - 1) % 1000000007 * C(j, p) %
                                 1000000007 * C(ps + 1 - j, q - p) %
                                 1000000007);
          }
        }
      }
    ps += sz[i];
  }
  printf("%d\n", dp[cnt][0]);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
