#include <bits/stdc++.h>
using namespace std;
const long long maxn = 65 + 5, maxk = (1 << 15) + 5, mod = 1e9 + 7,
                inf = 0x3f3f3f3f;
long long n, m, Q, K, T, S;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
long long a[maxn], jc[maxn], inv[maxn], du[maxn], ST[maxn];
long long q[maxn], top, cont[maxk], val[maxn];
long long cnt, tot, dp[maxn][maxk];
long long ans = 1;
long long kpow(long long x, long long k) {
  long long ans = 1, now = x;
  while (k) {
    if (k & 1) ans = 1ll * ans * now % mod;
    now = 1ll * now * now % mod, k >>= 1;
  }
  return ans;
}
bool cmp(long long x, long long y) { return x > y; }
long long C(long long a, long long b) {
  if (a < b) return 0;
  return 1ll * jc[a] * inv[b] % mod * inv[a - b] % mod;
}
void dfs(long long x, long long st) {
  if (ST[x]) return;
  ++tot, ST[x] = st;
  for (long long i = (1); i <= (n); ++i)
    if ((a[i] % a[x] == 0) || (a[x] % a[i] == 0)) dfs(i, st);
}
void clear() {
  top = 0;
  tot = 0;
  memset(cont, 0, sizeof(cont));
  memset(dp, 0, sizeof(dp));
}
signed main() {
  n = read();
  jc[0] = inv[0] = 1;
  for (long long i = (1); i <= (n); ++i)
    jc[i] = 1ll * jc[i - 1] * i % mod, inv[i] = kpow(jc[i], mod - 2);
  for (long long i = (1); i <= (n); ++i) a[i] = read();
  sort(a + 1, a + 1 + n);
  for (long long i = (1); i <= (n); ++i)
    for (long long j = (i + 1); j <= (n); ++j)
      if (!(a[j] % a[i])) ++du[j];
  for (long long T = (1); T <= (n); ++T) {
    if (ST[T]) continue;
    clear();
    dfs(T, T);
    for (long long i = (1); i <= (n); ++i)
      if (!du[i] && ST[i] == T) q[++top] = a[i];
    if (tot - top <= 1) continue;
    for (long long i = (1); i <= (n); ++i) {
      if (!du[i] || ST[i] != T) continue;
      for (long long j = (1); j <= (top); ++j)
        if (!(a[i] % q[j])) val[i] |= (1 << (j - 1));
    }
    S = (1 << top) - 1;
    for (long long s = (0); s <= (S); ++s)
      for (long long j = (1); j <= (n); ++j)
        if (ST[j] == T && du[j] && ((s & val[j]) == val[j])) ++cont[s];
    for (long long i = (1); i <= (n); ++i)
      if (ST[i] == T && du[i]) ++dp[1][val[i]];
    for (long long i = (1); i <= (tot - top - 1); ++i)
      for (long long s = (0); s <= (S); ++s) {
        if (!dp[i][s]) continue;
        if (cont[s] > i)
          dp[i + 1][s] =
              (dp[i + 1][s] + 1ll * dp[i][s] * (cont[s] - i) % mod) % mod;
        for (long long j = (1); j <= (n); ++j)
          if (ST[j] == T && du[j] && (s & val[j]) && ((s & val[j]) != val[j]))
            dp[i + 1][s | val[j]] = (dp[i + 1][s | val[j]] + dp[i][s]) % mod;
      }
    long long res = 0;
    tot -= top;
    for (long long s = (0); s <= (S); ++s) res = (res + dp[tot][s]) % mod;
    ans = 1ll * ans * res % mod * C(cnt + tot - 1, tot - 1) % mod;
    cnt += tot - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
