#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  char ch = getchar();
  x = 0;
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
}
const long long N = 62, M = 1 << 15 | 5, mod = 1e9 + 7;
long long n, res = 1, a[N], fa[N], in[N], C[N][N];
long long get(long long x) { return x == fa[x] ? x : fa[x] = get(fa[x]); }
long long c[N], s[N][N], S[N], f[M][N], g[M], o[N];
void prework() {
  for (long long i = 0; i <= n; ++i) C[i][0] = 1;
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= i; ++j)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n; ++i) fa[i] = i;
  for (long long i = 1; i <= n; ++i)
    for (long long j = i + 1; j <= n; ++j)
      if (a[j] % a[i] == 0) ++in[j], fa[get(i)] = get(j);
  for (long long i = 1, x; i <= n; ++i) x = get(i), s[x][++c[x]] = i;
}
signed main() {
  read(n);
  for (long long i = 1; i <= n; ++i) read(a[i]);
  prework();
  for (long long i = 1, t = 0; i <= n; ++i)
    if (c[i] > 1) {
      long long tp = 0, cnt = 0;
      for (long long j = 1; j <= c[i]; ++j)
        if (!in[s[i][j]]) S[++tp] = s[i][j];
      long long m = 1 << tp;
      memset(g, 0, sizeof(g));
      for (long long j = 1; j <= c[i]; ++j)
        if (in[s[i][j]]) {
          for (long long k = 1; k <= tp; ++k)
            if (!(a[s[i][j]] % a[S[k]])) o[s[i][j]] |= (1 << k - 1);
          ++cnt, ++g[o[s[i][j]]];
        }
      for (long long j = 1; j <= tp; ++j)
        for (long long k = 0; k < m; ++k)
          if (k >> (j - 1) & 1) g[k] += g[k - (1 << j - 1)];
      memset(f, 0, sizeof(f));
      f[0][0] = 1;
      for (long long j = 0; j < m; ++j) {
        for (long long k = 0; k <= cnt; ++k)
          if (f[j][k]) {
            if (k < g[j]) (f[j][k + 1] += f[j][k] * (g[j] - k)) %= mod;
            for (long long e = 1, x; e <= c[i]; ++e) {
              if (in[x = s[i][e]] && (o[x] & j) != o[x] && ((o[x] & j) || !j)) {
                (f[j | o[x]][k + 1] += f[j][k]) %= mod;
              }
            }
          }
      }
      res = res * f[m - 1][cnt] % mod * C[t += cnt - 1][cnt - 1] % mod;
    }
  return printf("%lld\n", res), 0;
}
