#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int f[1 << 15][61];
int x[16], num[61];
int cnt[1 << 15];
pair<int, int> solve(vector<int> vec) {
  int n = 0, m = 0;
  for (int i = 0; i < vec.size(); i++) {
    bool flag = true;
    for (int j = 0; j < vec.size(); j++)
      if (j != i && vec[i] % vec[j] == 0) flag = false;
    if (flag)
      x[n++] = vec[i];
    else
      num[m++] = vec[i];
  }
  if (!m) return make_pair(0, 1);
  for (int i = 0; i < m; i++) {
    int s = 0;
    for (int j = 0; j < n; j++)
      if (num[i] % x[j] == 0) s |= 1 << j;
    num[i] = s;
  }
  for (int s = 0; s < (1 << n); s++) {
    cnt[s] = 0;
    for (int i = 0; i < m; i++)
      if ((s | num[i]) == s) cnt[s]++;
  }
  f[0][0] = 1;
  for (int s = 0; s < (1 << n); s++)
    for (int c = 0; c <= m; c++) {
      if (!f[s][c]) continue;
      f[s][c + 1] = (f[s][c + 1] + 1ll * f[s][c] * (cnt[s] - c)) % Mod;
      for (int i = 0; i < m; i++) {
        if (s && !(s & num[i])) continue;
        int t = s | num[i];
        if (t <= s) continue;
        f[t][c + 1] = (f[t][c + 1] + f[s][c]) % Mod;
      }
    }
  pair<int, int> res = make_pair(m - 1, f[(1 << n) - 1][m]);
  for (int s = 0; s < (1 << n); s++)
    for (int c = 0; c <= m; c++) f[s][c] = 0;
  return res;
}
int a[61];
bool vis[61];
int C[61][61];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  C[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
  }
  int ans = 1;
  int S = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      vector<int> vec;
      vec.push_back(a[i]);
      vis[i] = true;
      int now = 0;
      while (now < vec.size()) {
        int u = vec[now];
        for (int j = 1; j <= n; j++)
          if (!vis[j] && (u % a[j] == 0 || a[j] % u == 0)) {
            vis[j] = true;
            vec.push_back(a[j]);
          }
        now++;
      }
      pair<int, int> pr = solve(vec);
      S += pr.first;
      ans = 1ll * ans * pr.second % Mod * C[S][pr.first] % Mod;
    }
  printf("%d\n", ans);
  return 0;
}
