#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 15, M = 62, mod = 1e9 + 7;
template <typename T>
void read(T &x) {
  int ch = getchar();
  x = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
int ksm(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = (long long)a * a % mod)
    if (b & 1) res = (long long)res * a % mod;
  return res;
}
void qmo(int &x) { x += x >> 31 & mod; }
int n, a[M], fa[M], deg[M], pre[N], sta[M], dp[M][N], ans = 1, res, fac[M],
                                                      inv[M];
vector<int> G[M], S;
int getfa(int u) { return u == fa[u] ? u : fa[u] = getfa(fa[u]); }
void init(int m) {
  fac[0] = 1;
  for (int i = 1; i <= m; ++i) fac[i] = (long long)fac[i - 1] * i % mod;
  inv[m] = ksm(fac[m], mod - 2);
  for (int i = m; i; --i) inv[i - 1] = (long long)inv[i] * i % mod;
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
    fa[i] = i;
  }
  sort(a + 1, a + n + 1);
  init(n);
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (!(a[j] % a[i])) {
        ++deg[j];
        int u = getfa(i), v = getfa(j);
        if (u != v) fa[u] = v;
      }
  for (int i = 1; i <= n; ++i) G[getfa(i)].emplace_back(i);
  for (int _ = 1; _ <= n; ++_)
    if (_ == fa[_] && G[_].size() > 1) {
      S.resize(0);
      for (int u : G[_])
        if (!deg[u]) S.emplace_back(u);
      int lim = 1 << S.size(), cnt = 0;
      memset(pre, 0, sizeof pre);
      for (int u : G[_])
        if (deg[u]) {
          ++cnt;
          for (int i = 0; i < S.size(); ++i)
            if (!(a[u] % a[S[i]])) sta[u] |= 1 << i;
          ++pre[sta[u]];
        }
      for (int i = 0; i <= cnt; ++i) memset(dp[i], 0, lim << 2);
      for (int i = 0; i < S.size(); ++i)
        for (int j = 0; j < lim; ++j)
          if (!(j >> i & 1)) qmo(pre[j | (1 << i)] += pre[j] - mod);
      dp[0][0] = 1;
      for (int i = 0; i < cnt; ++i)
        for (int j = 0; j < lim; ++j)
          if (dp[i][j]) {
            if (i < pre[j])
              dp[i + 1][j] =
                  (dp[i + 1][j] + (long long)(pre[j] - i) * dp[i][j]) % mod;
            for (int p : G[_])
              if (deg[p] && ((sta[p] & j) != sta[p]) && (!j || (sta[p] & j)))
                qmo(dp[i + 1][j | sta[p]] += dp[i][j] - mod);
          }
      ans = (long long)ans * dp[cnt][lim - 1] % mod * inv[cnt - 1] % mod;
      res += cnt - 1;
    }
  printf("%lld\n", (long long)ans * fac[res] % mod);
}
