#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 61, maxm = 2e4 + 10, lg = 15, mod = 1e9 + 7, inf = 1e18;
long long n, C[maxn][maxn], a[maxn], dp[1 << lg][maxn], res[maxn];
bool mk[maxn];
vector<long long> second, T;
void dfs(long long i) {
  if (mk[i]) return;
  mk[i] = 1;
  for (int j = 0; j < n; j++)
    if (!mk[j])
      if (a[i] % a[j] == 0 || a[j] % a[i] == 0) dfs(j);
  for (int j = 0; j < n; j++)
    if (i != j && a[i] % a[j] == 0) {
      T.push_back(a[i]);
      return;
    }
  second.push_back(a[i]);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  C[0][0] = 1;
  for (int i = 1; i < maxn; i++) {
    C[i][0] = 1;
    for (int j = 1; j < maxn; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long tt = 0, ans = 1;
  for (int i = 0; i < n; i++)
    if (!mk[i]) {
      dfs(i);
      if (T.empty()) {
        second.clear();
        continue;
      }
      tt += (long long)(T.size()) - 1;
      for (int i = 0; i < (long long)(second.size()); i++)
        for (int j = 0; j < (long long)(T.size()); j++)
          if (T[j] % second[i] == 0) res[j] ^= (1 << i);
      dp[0][0] = 1;
      for (int m = 0; m < (1 << (long long)(second.size())); m++) {
        for (int j = 0; j <= (long long)(T.size()); j++) {
          for (int i = 0; i < (long long)(T.size()); i++) {
            if (m && !(m & res[i])) continue;
            (dp[m | res[i]][j + 1] += dp[m][j]) %= mod;
          }
          ((dp[m][j + 1] -= dp[m][j] * j % mod) += mod) %= mod;
        }
      }
      (ans *= dp[(1 << (long long)(second.size())) - 1][(long long)(T.size())] *
              C[tt][(long long)(T.size()) - 1] % mod) %= mod;
      for (int m = 0; m < (1 << (long long)(second.size())); m++)
        for (int j = 0; j <= (long long)(T.size()); j++)
          dp[m][j] = 0, res[j] = 0;
      second.clear(), T.clear();
    }
  cout << ans;
  return 0;
}
