#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const int N = 302;
int len, num[N], m, n, a[N], dp[N][N], g[N][N], C[N][N];
int read() {
  int x = 0, f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9') {
    x = (x << 1) + (x << 3) + (s ^ 48);
    s = getchar();
  }
  return x * f;
}
void add(int &x, const int y) {
  x += y;
  x %= mod;
}
int main() {
  int x;
  long long tmp1, tmp2;
  bool flag;
  n = read();
  for (int i = 1; i <= n; ++i) {
    x = read();
    flag = 0;
    for (int j = 1; j <= m; ++j) {
      tmp1 = 1ll * a[j] * x;
      tmp2 = sqrt(tmp1);
      if (tmp2 * tmp2 == tmp1) {
        ++num[j];
        flag = 1;
        break;
      }
    }
    if (!flag) a[++m] = x, num[m] = 1;
  }
  dp[0][0] = g[0][0] = 1;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j)
      C[i][j] = (j == 0) ? 1 : (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= i; ++j)
      g[i][j] = (1ll * g[i - 1][j] * (i + j - 1) % mod +
                 1ll * j * g[i - 1][j - 1] % mod) %
                mod;
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j <= len; ++j)
      for (int k = 1; k <= num[i]; ++k)
        for (int l = 0; l <= j && l <= k; ++l)
          add(dp[i][j + (num[i] - k) - l], 1ll * dp[i - 1][j] * g[num[i]][k] %
                                               mod * C[j][l] % mod *
                                               C[len + 1 - j][k - l] % mod);
    len += num[i];
  }
  printf("%d\n", dp[m][0]);
  return 0;
}
