#include <bits/stdc++.h>
using namespace std;
const long long Size = 501;
const long long mod = 1e9 + 7;
long long a[Size], num[Size];
bool vis[Size];
long long f[Size], d[Size];
long long dp[Size][Size];
inline long long min(long long a, long long b) { return a < b ? a : b; }
inline long long max(long long a, long long b) { return a > b ? a : b; }
long long fastpow(long long b, long long p, long long k) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * b % k;
    b = b * b % k;
    p >>= 1;
  }
  return ans;
}
void init() {
  f[0] = 1;
  for (long long i = 1; i <= 300; i++) f[i] = f[i - 1] * i % mod;
  d[300] = fastpow(f[300], mod - 2, mod);
  for (long long i = 299; i >= 0; i--) d[i] = d[i + 1] * (i + 1) % mod;
}
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long C(long long a, long long b) {
  if (a < 0 || b < 0 || a < b) return 0;
  if (!b || a == b) return 1;
  return (f[a] * d[b] % mod) * d[a - b] % mod;
}
int main() {
  init();
  C(2, 1);
  long long n = read(), size = 0;
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      size++;
      for (long long j = i; j <= n; j++) {
        if (sqrt(a[i] * a[j]) == (long long)sqrt(a[i] * a[j])) {
          vis[j] = true;
          num[size]++;
        }
      }
    }
  }
  long long sum = num[1] - 1;
  dp[1][sum] = 1;
  for (long long i = 2; i <= size; sum += num[i++]) {
    for (long long j = 0; j <= sum; j++) {
      if (!dp[i - 1][j]) continue;
      for (long long k = 0; k <= num[i]; k++) {
        long long tmp = min(j, k + 1), temp;
        for (long long l = 0; l <= tmp; l++) {
          temp = dp[i - 1][j] * C(num[i] - 1, k) % mod * C(j, l) % mod *
                 C(sum + 2 - j, k - l + 1) % mod;
          dp[i][j + num[i] - 1 - k - l] += temp;
          dp[i][j + num[i] - 1 - k - l] %= mod;
        }
      }
    }
  }
  long long ans = dp[size][0];
  for (long long i = 1; i <= size; i++) ans = ans * f[num[i]] % mod;
  printf("%I64d", ans);
  return 0;
}
