#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline void writeln(int x) {
  char buffor[21];
  register int i = 0;
  int neg = 0;
  if (x < 0) {
    neg = 1;
    x = -x;
  }
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
const int N = 310;
const long long base = (long long)1e9 + 7;
int n, sz[N], gr[N], num;
long long a[N];
long long gt[N];
long long f[N][N], c[N][N];
void input() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  num = 0;
  for (int i = 1; i <= n; i++)
    if (!gr[i]) {
      num++;
      gr[i] = num;
      for (int j = i + 1; j <= n; j++) {
        long long can = (long long)sqrt(a[i] * a[j]);
        if (can * can == a[i] * a[j]) gr[j] = gr[i];
      }
    }
  for (int i = 1; i <= n; i++) sz[gr[i]]++;
}
long long power(long long x, long long k) {
  if (k == 1) return x;
  long long tmp = power(x, k / 2);
  if (k % 2 == 0)
    return tmp * tmp % base;
  else
    return ((tmp * tmp) % base * x) % base;
}
long long CC(int k, int n) {
  if (k > n) return 0;
  return gt[n] * power(gt[k] * gt[n - k] % base, base - 2) % base;
}
long long C(int k, int n) { return c[k][n]; }
void Add(long long &a, long long b) { a = (a + b) % base; }
void solve() {
  gt[0] = 1;
  for (int i = 1; i <= N - 1; i++) gt[i] = gt[i - 1] * i % base;
  for (int k = 0; k <= N - 1; k++)
    for (int n = k; n <= N - 1; n++) c[k][n] = CC(k, n);
  int total = 0;
  f[0][0] = 1;
  for (int i = 0; i <= num - 1; i++) {
    for (int j = 0; j <= total; j++)
      if (f[i][j]) {
        for (int S = 1; S <= min(sz[i + 1], total + 1); S++)
          for (int D = 0; D <= min(j, S); D++) {
            long long T = ((C(S - 1, sz[i + 1] - 1) * C(D, j) % base) *
                           C(S - D, total + 1 - j) % base);
            Add(f[i + 1][j - D + sz[i + 1] - S], f[i][j] * T % base);
          };
      }
    total += sz[i + 1];
  };
  long long res = f[num][0];
  for (int i = 1; i <= num; i++) res = res * gt[sz[i]] % base;
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  solve();
  return 0;
}
