#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9 + 7;
int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b) { return 1ll * a * b % Mod; }
void Add(int &a, int b) { a = add(a, b); }
void Dec(int &a, int b) { a = dec(a, b); }
void Mul(int &a, int b) { a = mul(a, b); }
int ksm(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, Mul(a, a))
    if (b & 1) Mul(ans, a);
  return ans;
}
const int N = 1 << 15 | 5, M = 65;
int n, a[M], fa[M], in[M], fc[M], ifc[M];
int fnd(int x) { return x == fa[x] ? x : fa[x] = fnd(fa[x]); }
vector<int> G[M];
int sm[N], dp[N][M], e[M];
int main() {
  cin >> n;
  fc[0] = fc[1] = ifc[0] = ifc[1] = 1;
  for (int i = 2; i <= n; i++) fc[i] = mul(fc[i - 1], i);
  ifc[n] = ksm(fc[n], Mod - 2);
  for (int i = n - 1; i >= 2; i--) ifc[i] = mul(ifc[i + 1], i + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), fa[i] = i;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (a[j] % a[i] == 0) ++in[j], fa[fnd(i)] = fnd(j);
  for (int i = 1; i <= n; i++) G[fnd(i)].push_back(i);
  int all = 0, ans = 1;
  for (int i = 1; i <= n; i++)
    if (G[i].size() > 1) {
      vector<int> S;
      int ct = 0;
      for (int z : G[i])
        if (!in[z])
          S.push_back(z);
        else
          ++ct;
      all += ct - 1;
      memset(sm, 0, sizeof(sm));
      memset(dp, 0, sizeof(dp));
      int U = 1 << S.size();
      for (int z : G[i])
        if (in[z]) {
          e[z] = 0;
          for (int j = 0; j < S.size(); j++)
            if (a[z] % a[S[j]] == 0) e[z] |= 1 << j;
          ++sm[e[z]];
        }
      for (int j = 0; j < S.size(); j++)
        for (int k = 0; k < U; k++)
          if (k >> j & 1) Add(sm[k], sm[k - (1 << j)]);
      dp[0][0] = 1;
      for (int j = 0; j < U; j++)
        for (int k = 0, c; k <= ct; k++)
          if (c = dp[j][k]) {
            if (k < sm[j]) Add(dp[j][k + 1], mul(sm[j] - k, c));
            for (int z : G[i])
              if (in[z] && ((e[z] & j) != e[z]) && ((e[z] & j) || !j))
                Add(dp[j | e[z]][k + 1], c);
          }
      Mul(ans, mul(dp[U - 1][ct], ifc[ct - 1]));
    }
  cout << mul(ans, fc[all]);
  return 0;
}
