#include <bits/stdc++.h>
using namespace std;
const long long N = 67;
const long long M = 4e4 + 7;
const long long mod = 1e9 + 7;
long long Pow(long long x, long long y) {
  long long ans = 1, now = x;
  while (y) {
    if (y & 1) ans = ans * now % mod;
    now = now * now % mod;
    y >>= 1;
  }
  return ans;
}
long long n, c1 = 0, c2 = 0, iv2;
long long a[N], s[N], t[N], tc[N], g[M], f[N][M], sz[N], fac[N], inv[N], fa[N];
long long ff(long long x) { return (fa[x] == x) ? x : fa[x] = ff(fa[x]); }
long long C(long long x, long long y) {
  if (x < y || y < 0) return 0;
  return fac[x] * inv[y] % mod * inv[x - y] % mod;
}
void mer(long long x, long long y) {
  long long u = ff(x), v = ff(y);
  if (u != v) {
    fa[u] = v;
    sz[v] += sz[u];
  }
}
long long rs[N], rt[N], rc[N], ts[N];
long long solve(long long x) {
  long long cnt1 = 0, cnt2 = 0;
  for (long long i = 0; i <= c1 - 1; i++)
    if (ff(i) == x) rs[cnt1++] = s[i];
  for (long long i = 0; i <= c2 - 1; i++) {
    if (ff(i + c1) == x) {
      rc[cnt2] = tc[i];
      rt[cnt2++] = t[i];
    }
  }
  if (!cnt1 || !cnt2) return 1;
  for (long long i = 0; i <= (1 << cnt1) - 1; i++) g[i] = 0;
  for (long long i = 0; i <= cnt2 - 1; i++) {
    ts[i] = 0;
    for (long long j = 0; j <= cnt1 - 1; j++)
      if (rt[i] % rs[j] == 0) ts[i] |= (1 << j);
    g[ts[i]] += rc[i];
  }
  for (long long i = 0; i <= cnt1 - 1; i++)
    for (long long j = 0; j <= (1 << cnt1) - 1; j++)
      if ((j >> i) & 1) g[j] += g[j - (1 << i)];
  for (long long i = 1; i <= cnt2; i++)
    for (long long j = 0; j <= (1 << cnt1) - 1; j++) f[i][j] = 0;
  for (long long i = 0; i <= cnt2 - 1; i++) {
    long long u = rc[i];
    for (long long j = 0; j <= cnt1 - 1; j++)
      if (rs[j] == rt[i]) u = u * iv2 % mod * (rc[i] + 1) % mod;
    f[1][ts[i]] = (f[1][ts[i]] + u) % mod;
  }
  for (long long i = 1; i <= cnt2 - 1; i++) {
    for (long long j = 0; j <= (1 << cnt1) - 1; j++) {
      if (i < g[j]) f[i + 1][j] = (f[i + 1][j] + f[i][j] * (g[j] - i)) % mod;
      for (long long k = 0; k <= cnt2 - 1; k++) {
        if ((ts[k] | j) == j || !(ts[k] & j)) continue;
        f[i + 1][j | ts[k]] = (f[i + 1][j | ts[k]] + f[i][j]) % mod;
      }
    }
  }
  return f[cnt2][(1 << cnt1) - 1];
}
int main() {
  iv2 = Pow(2, mod - 2);
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n; i++) {
    bool fl = 1;
    for (long long j = 1; j <= i - 1; j++)
      if (a[i] % a[j] == 0) {
        fl = 0;
        break;
      }
    if (fl)
      s[c1++] = a[i];
    else {
      if (!c2 || t[c2 - 1] != a[i]) {
        tc[c2] = 1;
        t[c2++] = a[i];
      } else
        tc[c2 - 1]++;
    }
  }
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  inv[n] = Pow(fac[n], mod - 2);
  for (long long i = n; i; i--) inv[i - 1] = inv[i] * i % mod;
  for (long long i = 0; i <= c1 + c2 - 1; i++) fa[i] = i;
  for (long long i = 0; i <= c2 - 1; i++) sz[i + c1] = 1;
  for (long long i = 0; i <= c2 - 1; i++)
    for (long long j = 0; j <= c1 - 1; j++)
      if (t[i] % s[j] == 0) mer(i + c1, j);
  long long nw = 0, ans = 1;
  for (long long i = 0; i <= c1 + c2 - 1; i++) {
    if (ff(i) == i) {
      if (!sz[i]) continue;
      nw += sz[i] - 1;
      ans = ans * C(nw, sz[i] - 1) % mod * solve(i) % mod;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
