#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T, class U>
inline void print(T first, U second) {
  printsp(first);
  println(second);
}
template <class T, class U, class V>
inline void print(T first, U second, V z) {
  printsp(first);
  printsp(second);
  println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int fac[1010], C[1010][1010];
map<int, int> mp;
int dp[2][1010];
inline int H(int n, int k) { return C[n + k - 1][k]; }
int main() {
  int n;
  gn(n);
  for (int i = 0; i < n; i++) {
    int u, v = 1;
    gn(u);
    for (int j = 2; j * j <= u; j++)
      if (u % j == 0) {
        int cnt = 0;
        while (u % j == 0) u /= j, cnt++;
        if (cnt & 1) v *= j;
      }
    v *= u;
    mp[v]++;
  }
  for (int i = fac[0] = 1; i < 1010; i++)
    fac[i] = (long long)fac[i - 1] * i % 1000000007;
  for (int i = 0; i < 1010; i++)
    for (int j = 0; j <= i; j++) {
      if (j == 0 || i == j)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % 1000000007;
    }
  int ok = 0, sum = mp.begin()->second - 1, len = sum + 1;
  dp[0][sum] = fac[len];
  for (map<int, int>::iterator it = ++mp.begin(); it != mp.end(); it++) {
    ok ^= 1;
    int cnt = it->second;
    for (int i = 0; i <= n + 1; i++) dp[ok][i] = 0;
    for (int i = 0; i < sum + cnt; i++) {
      for (int j = 0; j <= sum; j++) {
        for (int k = 0; k <= j && k <= i; k++) {
          int t = cnt - i + k, tt = t - (j - k);
          if (tt < 0 || t < 0 || len + 1 - j < tt) continue;
          dp[ok][i] += (long long)dp[ok ^ 1][j] * C[len + 1 - j][tt] %
                       1000000007 * H(t, cnt - t) % 1000000007 * C[j][k] %
                       1000000007;
          dp[ok][i] %= 1000000007;
        }
      }
    }
    for (int i = 0; i <= n + 1; i++)
      dp[ok][i] = (long long)dp[ok][i] * fac[cnt] % 1000000007;
    sum += cnt - 1;
    len += cnt;
  }
  println(dp[ok][0]);
  return 0;
}
