#include <bits/stdc++.h>
using namespace std;
const double pi = acos(0.0) * 2.0;
const long double eps = 1e-10;
const int step[8][2] = {{-1, 0}, {0, 1}, {1, 0},  {0, -1},
                        {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};
template <class T>
inline T abs1(T a) {
  return a < 0 ? -a : a;
}
template <typename t, typename t1>
t min1(t a, t1 b) {
  return a < b ? a : b;
}
template <typename t, typename... arg>
t min1(t a, arg... arr) {
  return min1(a, min1(arr...));
}
template <typename t, typename t1>
t max1(t a, t1 b) {
  return a > b ? a : b;
}
template <typename t, typename... arg>
t max1(t a, arg... arr) {
  return max1(a, max1(arr...));
}
inline int jud(double a, double b) {
  if (abs(a) < eps && abs(b) < eps)
    return 0;
  else if (abs1(a - b) / max(abs1(a), abs1(b)) < eps)
    return 0;
  if (a < b) return -1;
  return 1;
}
template <typename t>
inline int jud(t a, t b) {
  if (a < b) return -1;
  if (a == b) return 0;
  return 1;
}
template <typename it, typename t1>
inline int RangeFind(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1) {
  if (na == 0) return 0;
  int be = 0, en = na - 1;
  if (*a <= *(a + na - 1)) {
    if (f_lb == 0)
      while (be < en) {
        int mid = (be + en + 1) / 2;
        if (jud(*(a + mid), val) != 1)
          be = mid;
        else
          en = mid - 1;
      }
    else
      while (be < en) {
        int mid = (be + en) / 2;
        if (jud(*(a + mid), val) != -1)
          en = mid;
        else
          be = mid + 1;
      }
    if (f_small && jud(*(a + be), val) == 1) be--;
    if (!f_small && jud(*(a + be), val) == -1) be++;
  } else {
    if (f_lb)
      while (be < en) {
        int mid = (be + en + 1) / 2;
        if (jud(*(a + mid), val) != -1)
          be = mid;
        else
          en = mid - 1;
      }
    else
      while (be < en) {
        int mid = (be + en) / 2;
        if (jud(*(a + mid), val) != 1)
          en = mid;
        else
          be = mid + 1;
      }
    if (!f_small && jud(*(a + be), val) == -1) be--;
    if (f_small && jud(*(a + be), val) == 1) be++;
  }
  return be;
}
template <class T>
inline T lowb(T num) {
  return num & (-num);
}
inline int bitnum(unsigned int nValue) { return __builtin_popcount(nValue); }
inline int bitnum(int nValue) { return __builtin_popcount(nValue); }
inline int bitnum(unsigned long long nValue) {
  return __builtin_popcountll(nValue);
}
inline int bitnum(long long nValue) { return __builtin_popcountll(nValue); }
inline int bitmaxl(unsigned int a) {
  if (a == 0) return 0;
  return 32 - __builtin_clz(a);
}
inline int bitmaxl(int a) {
  if (a == 0) return 0;
  return 32 - __builtin_clz(a);
}
inline int bitmaxl(unsigned long long a) {
  if (a == 0) return 0;
  return 64 - __builtin_clzll(a);
}
inline int bitmaxl(long long a) {
  if (a == 0) return 0;
  return 64 - __builtin_clzll(a);
}
long long pow(long long n, long long m, long long mod = 0) {
  if (m < 0) return 0;
  long long ans = 1;
  long long k = n;
  while (m) {
    if (m & 1) {
      ans *= k;
      if (mod) ans %= mod;
    }
    k *= k;
    if (mod) k %= mod;
    m >>= 1;
  }
  return ans;
}
template <class t1, class t2>
inline void add(t1& a, t2 b, int mod = -1) {
  if (mod == -1) mod = 1000000007;
  a += b;
  while (a >= mod) a -= mod;
  while (a < 0) a += mod;
}
template <class t>
void output1(t arr) {
  for (int i = 0; i < (int)arr.size(); i++) cerr << arr[i] << ' ';
  cerr << endl;
}
template <class t>
void output2(t arr) {
  for (int i = 0; i < (int)arr.size(); i++) output1(arr[i]);
}
const int maxn = 66;
const int mod = 1000000007;
int n;
int orig[maxn], lr1, lr2, divisable[maxn];
vector<int> e[maxn];
int cnt[1 << 15];
int have[maxn];
long long c[maxn][maxn], fac[maxn];
long long dp[1 << 15][maxn];
int main() {
  ios_base::sync_with_stdio(0);
  for (int i = 0; i < maxn; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
      c[i][j] %= mod;
    }
  }
  fac[0] = fac[1] = 1;
  for (int i = 2; i < maxn; i++) fac[i] = fac[i - 1] * i % mod;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", orig + i);
  for (int i = 0; i < n; i++) {
    divisable[i] = 0;
    for (int j = 0; j < n; j++)
      if (j != i && orig[i] % orig[j] == 0) {
        divisable[i] = 1;
        e[i].push_back(j);
        e[j].push_back(i);
      }
  }
  int sum = 0;
  long long ans = 1;
  for (int i = 0; i < n; i++)
    if (!have[i]) {
      map<int, int> r[2];
      int q[maxn], lq = 0;
      q[lq++] = i;
      r[divisable[i]][i] = -1;
      for (int j = 0; j < lq; j++) {
        int no = q[j];
        have[no] = 1;
        for (auto it : e[no]) {
          if (r[divisable[it]].find(it) == r[divisable[it]].end()) {
            q[lq++] = it;
            r[divisable[it]][it] = -1;
          }
        }
      }
      vector<int> vr[2];
      for (int cate = 0; cate < 2; cate++) {
        int last = 0;
        for (auto& it : r[cate]) {
          vr[cate].push_back(it.first);
          it.second = last++;
        }
      }
      vector<long long> e_mask[2];
      for (int cate = 0; cate < 2; cate++) {
        for (int j = 0; j < (int)vr[cate].size(); j++) {
          int no = vr[cate][j];
          e_mask[cate].push_back(0);
          for (const auto it : e[no])
            if (divisable[it] != divisable[no]) {
              e_mask[cate][j] |= 1ll << r[divisable[it]][it];
            }
        }
      }
      for (long long mask = 0; mask < 1ll << vr[0].size(); mask++)
        for (int j = 0; j <= (int)vr[1].size(); j++) {
          dp[mask][j] = 0;
        }
      dp[0][0] = 1;
      for (long long mask = 0; mask < 1ll << vr[0].size(); mask++) {
        long long cnt = 0;
        for (int j = 0; j < (int)vr[1].size(); j++)
          if ((mask & e_mask[1][j]) == e_mask[1][j]) {
            cnt++;
          }
        for (int j = 0; j <= cnt; j++)
          if (dp[mask][j]) {
            if (j < cnt) {
              dp[mask][j + 1] += 1ll * (cnt - j) * dp[mask][j];
              dp[mask][j + 1] %= mod;
            }
            for (int t = 0; t < (int)vr[1].size(); t++) {
              if ((mask & e_mask[1][t]) != e_mask[1][t] &&
                  ((mask & e_mask[1][t]) || mask == 0)) {
                add(dp[mask | e_mask[1][t]][j + 1], dp[mask][j]);
              }
            }
          }
      }
      if (vr[1].size() != 0) {
        long long multi = max(dp[(1 << vr[0].size()) - 1][vr[1].size()], 1ll);
        ans = ans * multi % mod * c[sum + vr[1].size() - 1][sum] % mod;
        sum += vr[1].size() - 1;
      }
    }
  cout << ans << endl;
  return 0;
}
