#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 2000000000;
const long long BIG = 1446803456761533460LL;
const int maxn = 60;
const int maxa = 10;
int n, A[maxn], ent[maxn][maxn], Ai[maxn], Aj[maxn], ain, ajn,
    dp[maxn][1 << maxa], inAi[maxn];
vector<int> out[maxn], in[maxn];
bool vis[maxn];
void dfs(int x) {
  vis[x] = 1;
  if (A[x] <= maxn / 3 && in[x].empty())
    Ai[ain++] = A[x];
  else if (!in[x].empty())
    Aj[ajn++] = A[x];
  for (auto y : out[x])
    if (!vis[y]) dfs(y);
  for (auto y : in[x])
    if (!vis[y]) dfs(y);
}
int calc() {
  memset(dp, 0, sizeof dp);
  memset(inAi, 0, sizeof inAi);
  for (int i = 0; i < ain; ++i)
    for (int j = 0; j < ajn; ++j) {
      if (Aj[j] % Ai[i] == 0) inAi[j] ^= 1 << i;
    }
  for (int j = 0; j < ajn; ++j) ++dp[0][inAi[j]];
  for (int j = 0; j < ajn - 1; ++j)
    for (int mask = 0; mask < 1 << ain; ++mask)
      if (dp[j][mask]) {
        int sub = 0;
        for (int k = 0; k < ajn; ++k) {
          if (inAi[k] & mask) {
            if ((inAi[k] | mask) == mask)
              ++sub;
            else
              dp[j + 1][mask | inAi[k]] =
                  ((dp[j + 1][mask | inAi[k]]) + (dp[j][mask])) % MOD;
          }
        }
        dp[j + 1][mask] =
            ((dp[j + 1][mask]) + (1LL * dp[j][mask] * (sub - (j + 1)))) % MOD;
      }
  return dp[ajn - 1][(1 << ain) - 1];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  fill(ent[0], ent[0] + maxn, 1);
  for (int i = 0; i < maxn - 1; ++i)
    for (int j = 0; j < maxn - 1; ++j)
      ent[i + 1][j + 1] = (ent[i][j] + ent[i + 1][j]) % MOD;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> A[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (A[i] < A[j] && A[j] % A[i] == 0) {
        out[i].emplace_back(j);
        in[j].emplace_back(i);
      }
    }
  int ans = 1, sz = 0;
  for (int i = 0; i < n; ++i)
    if (!vis[i]) {
      ain = ajn = 0;
      dfs(i);
      if (ajn == 0) continue;
      int t = calc();
      sz += ajn - 1;
      ans = (1LL * (ans) * (1LL * t * ent[ajn - 1][sz] % MOD)) % MOD;
    }
  cout << ans << '\n';
}
