#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
const long long maxn = 64, mod = 1e9 + 7, INF = 1e9, lg = 15 + 1, SQRT = 400;
int n, a[maxn], par[maxn], SZ_T[maxn], FAC[maxn], INV[maxn];
vector<int> adj1[maxn], adj2[maxn], cmp;
long long dp[(1 << lg)][maxn], ans[maxn];
bool mark[maxn];
inline long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    b /= 2;
    a = (a * a) % mod;
  }
  return res;
}
inline void make_graph() {
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[j] % a[i] == 0) {
        adj1[i].push_back(j);
        adj1[j].push_back(i);
      }
    }
  }
}
void dfs(int v) {
  mark[v] = 1;
  cmp.push_back(a[v]);
  for (auto u : adj1[v]) {
    if (!mark[u]) {
      dfs(u);
    }
  }
}
inline void get(int cnt) {
  memset(dp, 0, sizeof dp);
  sort(cmp.begin(), cmp.end());
  vector<int> s, t;
  for (int i = 0; i < cmp.size(); ++i) {
    bool is = 0;
    for (int j = 0; j < i; ++j) {
      if (cmp[i] % cmp[j] == 0) is = 1;
    }
    if (!is) {
      s.push_back(cmp[i]);
    } else {
      t.push_back(cmp[i]);
    }
  }
  for (int i = 0; i < t.size(); ++i) {
    par[i] = 0;
    for (int j = 0; j < s.size(); ++j) {
      if (t[i] % s[j] == 0) {
        par[i] |= (1 << j);
      }
    }
  }
  SZ_T[cnt] = t.size();
  if (!t.size()) {
    ans[cnt] = 1;
    return;
  }
  for (int i = 0; i < t.size(); ++i) {
    dp[par[i]][1]++;
  }
  for (int mask = 0; mask < (1 << s.size()); ++mask) {
    for (int i = 0; i < t.size(); ++i) {
      int counter = 0;
      for (int j = 0; j < t.size(); ++j) {
        if ((mask | par[j]) == mask) {
          counter++;
        } else if (mask & par[j]) {
          dp[mask | par[j]][i + 1] =
              (dp[mask][i] + dp[mask | par[j]][i + 1]) % mod;
        }
      }
      if (counter > i)
        dp[mask][i + 1] =
            (dp[mask][i + 1] + (dp[mask][i] * (counter - i)) % mod) % mod;
    }
  }
  ans[cnt] = dp[(1 << s.size()) - 1][t.size()];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  FAC[0] = INV[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    FAC[i] = (FAC[i - 1] * i) % mod;
    INV[i] = power(FAC[i], mod - 2);
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  make_graph();
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (!mark[i]) {
      dfs(i);
      get(cnt);
      cnt++;
      cmp.clear();
    }
  }
  long long res = 1, SZ = 0;
  for (int i = 0; i < cnt; ++i) {
    res = (res * ans[i]) % mod;
    SZ += max(SZ_T[i] - 1, 0);
  }
  long long h = FAC[SZ];
  for (int i = 0; i < cnt; ++i) {
    h = (h * INV[max(SZ_T[i] - 1, 0)]) % mod;
  }
  res = (res * h) % mod;
  cout << res << endl;
}
