#include <bits/stdc++.h>
using namespace std;
const long long MAC = 55000, N = 66, mod = 1e9 + 7;
long long nn;
long long a[N], in[N];
struct nod {
  long long to, nxt;
} e[N * 5];
long long head[N], cnt;
void add(long long u, long long v) {
  e[++cnt].to = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
inline long long ksm(long long a, long long x) {
  long long tot = 1;
  while (x) {
    if (x & 1ll) tot = 1ll * tot * a % mod;
    a = 1ll * a * a % mod;
    x >>= 1ll;
  }
  return tot;
}
long long v[N], id;
long long pre[N];
bool viss[N], vis[N];
void dfs(long long u) {
  vis[u] = 1;
  for (long long i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (vis[v]) continue;
    dfs(v);
  }
}
long long fa[N];
long long getf(long long x) {
  if (x == fa[x]) return x;
  return fa[x] = getf(fa[x]);
}
void merge(long long x, long long y) {
  long long fx = getf(x), fy = getf(y);
  fa[fx] = fy;
}
long long dp[MAC][N];
long long q[N], n;
long long mul[N], inv[N], ans = 1, tot;
int main() {
  long long lim = N - 5;
  mul[0] = inv[0] = 1;
  for (long long i = 1; i <= lim; i++) mul[i] = 1ll * mul[i - 1] * i % mod;
  inv[lim] = ksm(mul[lim], mod - 2);
  for (long long i = lim - 1; i >= 1; i--)
    inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
  cin >> nn;
  for (long long i = 1; i <= nn; i++) cin >> a[i], fa[i] = i;
  for (long long i = 1; i <= nn; i++) {
    for (long long j = 1; j <= nn; j++) {
      if (i != j && a[j] % a[i] == 0) {
        in[j]++, add(i, j), merge(i, j);
      }
    }
  }
  for (long long l = 1; l <= nn; l++) {
    if (viss[l]) continue;
    n = 0;
    for (long long i = 1; i <= nn; i++)
      if (getf(i) == l) q[++n] = i;
    if (n <= 2) continue;
    memset(pre, 0, sizeof(pre));
    id = 0;
    for (long long i = 1; i <= n; i++)
      if (!in[q[i]]) v[id++] = q[i];
    tot += n - id - 1;
    ans = ans * inv[n - id - 1] % mod;
    for (long long i = 0; i < id; i++) {
      memset(vis, 0, sizeof(vis));
      dfs(v[i]);
      for (long long j = 1; j <= n; j++)
        if (vis[q[j]]) pre[j] |= (1 << i);
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (long long mac = 0; mac < (1 << id); mac++) {
      long long cs = 0;
      for (long long i = 1; i <= n; i++)
        if (in[q[i]] && (pre[i] | mac) == mac) cs++;
      for (long long t = 0; t < cs; t++)
        dp[mac][t + 1] = (dp[mac][t + 1] + dp[mac][t] * (cs - t) % mod) % mod;
      for (long long t = 0; t <= n; t++)
        for (long long i = 1; i <= n; i++)
          if (in[q[i]] && (pre[i] | mac) != mac && (mac == 0 || (mac & pre[i])))
            dp[pre[i] | mac][t + 1] =
                (dp[pre[i] | mac][t + 1] + dp[mac][t]) % mod;
    }
    ans = ans * dp[(1 << id) - 1][n - id] % mod;
  }
  cout << ans * mul[tot] % mod;
}
