#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, a[100], fa[100], id[100], S[100], cnt[40000], dp[100][40000],
    c[200][200];
bool not_mn[100];
int find(int a) { return fa[a] == a ? a : fa[a] = find(fa[a]); }
void merge(int u, int v) {
  int fu = find(u), fv = find(v);
  if (fu == fv) return;
  fa[fu] = fv;
}
int C(int n, int m) {
  if (n < m) return 0;
  if (n == m || m == 0) return 1;
  if (c[n][m]) return c[n][m];
  return C(n - 1, m) + C(n - 1, m - 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), fa[i] = i;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (i != j && a[i] % a[j] == 0) merge(i, j), not_mn[i] |= true;
  }
  int ans = 1, tot = 0;
  for (int p = 1; p <= n; p++)
    if (find(p) == p) {
      memset(dp, 0, sizeof(dp));
      int num = 0, c = 0;
      for (int i = 1; i <= n; i++)
        if (find(i) == p && !not_mn[i]) id[i] = ++c;
      for (int i = 1; i <= n; i++)
        if (find(i) == p && not_mn[i]) {
          num++;
          for (int j = 1; j <= n; j++)
            if (!not_mn[j] && a[i] % a[j] == 0) S[i] |= (1 << (id[j] - 1));
        }
      if (!num) continue;
      for (int T = 0; T < (1 << c); T++) {
        cnt[T] = 0;
        for (int i = 1; i <= n; i++)
          if (find(i) == p && (S[i] | T) == T && not_mn[i]) cnt[T]++;
      }
      for (int i = 1; i <= n; i++)
        if (find(i) == p && not_mn[i]) dp[1][S[i]]++;
      for (int i = 1; i < num; i++)
        for (int T = 0; T < (1 << c); T++)
          if (dp[i][T]) {
            dp[i + 1][T] = (dp[i + 1][T] + 1ll * dp[i][T] * (cnt[T] - i)) % mod;
            for (int j = 1; j <= n; j++)
              if (find(j) == p && not_mn[j] && (S[j] & T) && (S[j] | T) != T) {
                dp[i + 1][S[j] | T] = (dp[i + 1][S[j] | T] + dp[i][T]) % mod;
              }
          }
      ans =
          1ll * ans * dp[num][(1 << c) - 1] % mod * C(tot + num - 1, tot) % mod;
      tot += num - 1;
    }
  printf("%d\n", ans);
}
