#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m, a[66], fa[66], f[66][1 << 15], pri[66], s[66], cnt[1 << 15],
    C[66][66], sz, tt;
int getf(int x) { return x == fa[x] ? x : fa[x] = getf(fa[x]); }
int cal(int x) {
  memset(f, 0, sizeof(f));
  memset(cnt, 0, sizeof(cnt));
  sz = 0;
  for (int i = 1; i <= n; i++)
    if (getf(i) == x) {
      ++sz, ++f[1][s[i]];
      for (int j = 0; j < (1 << m); j++)
        if ((s[i] & j) == s[i]) ++cnt[j];
    }
  for (int i = 1; i < sz; i++)
    for (int j = 0; j < (1 << m); j++) {
      if (f[i][j]) {
        f[i + 1][j] = (f[i + 1][j] + 1ll * f[i][j] * (cnt[j] - i)) % mod;
        for (int k = 1; k <= n; k++)
          if ((j & s[k]) != 0 && (j | s[k]) != j)
            f[i + 1][j | s[k]] = (f[i + 1][j | s[k]] + f[i][j]) % mod;
      }
    }
  int ret = 0;
  for (int i = 0; i < (1 << m); i++) ret = (ret + f[sz][i]) % mod;
  return ret;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], fa[i] = i;
  for (int i = 0; i <= n; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
  }
  memset(pri, -1, sizeof(pri));
  for (int i = 1; i <= n; i++) {
    bool fl = 1, fl2 = 0;
    for (int j = 1; j <= n; j++)
      if (i != j && a[i] % a[j] == 0) fl = 0;
    for (int j = 1; j <= n; j++)
      if (i != j && a[j] % a[i] == 0) fl2 = 1;
    if (fl && fl2) pri[i] = m++;
  }
  for (int i = 1; i <= n; i++)
    if (!~pri[i])
      for (int j = 1; j <= n; j++)
        if (~pri[j] && a[i] % a[j] == 0) s[i] |= 1 << pri[j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (s[i] & s[j]) fa[getf(i)] = getf(j);
  int ans = 1;
  for (int i = 1; i <= n; i++)
    if (!~pri[i] && getf(i) == i)
      ans = 1ll * ans * cal(i) % mod * C[tt + sz - 1][tt] % mod, tt += sz - 1;
  cout << ans;
  return 0;
}
