#include <bits/stdc++.h>
using namespace std;
int n, mod = 1e9 + 7;
long long a[305], fac[1005], comb[1005][1005], dp[1005][1005];
bitset<305> bs;
vector<int> v;
int acu = 1;
long long C(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  if (n == k || k == 0) return 1;
  if (comb[n][k] != -1) return comb[n][k];
  return comb[n][k] = (C(n - 1, k) + C(n - 1, k - 1)) % mod;
}
bool esCP(long long n) {
  long long d = sqrt(n);
  for (int i = -2; i <= 2; i++)
    if ((d + i) * (d + i) == n) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 1005; i++) {
    fill(comb[i], comb[i] + 1005, -1);
    fac[i] = (i ? fac[i - 1] * i : 1) % mod;
  }
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (!bs[i]) {
      v.push_back(1);
      for (int j = i + 1; j < n; j++) {
        if (esCP(a[i] * a[j])) {
          v.back()++;
          bs[j] = 1;
        }
      }
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i < v.size(); i++) {
    for (int b = 0; b <= acu; b++) {
      for (int s = 1; s <= min(acu, v[i]); s++) {
        for (int e = 0; e <= min(s, b); e++) {
          int f = s - e;
          int g = acu - b;
          long long res = fac[v[i]];
          res *= dp[i][b];
          res %= mod;
          res *= C(v[i] - 1, s - 1);
          res %= mod;
          res *= C(b, e);
          res %= mod;
          res *= C(g, f);
          res %= mod;
          dp[i + 1][b - e + v[i] - s] += res;
          dp[i + 1][b - e + v[i] - s] %= mod;
        }
      }
    }
    acu += v[i];
  }
  cout << dp[v.size()][0] << '\n';
  return 0;
}
