#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, m, a[401], f[1 << 15][71], g[1 << 15], fa[10001], in[1001],
    c[201][201];
long long peach[1 << 15], ans = 1, hd = 0;
vector<long long> vec[101], Vec;
long long g_fa(long long x) {
  if (fa[x] == x)
    return x;
  else
    return g_fa(fa[x]);
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(1 + a, 1 + a + n);
  for (long long i = 1; i <= n; i++) fa[i] = i;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      if (a[j] % a[i] == 0) {
        long long t1 = g_fa(i), t2 = g_fa(j);
        in[j]++;
        if (t1 ^ t2) fa[t2] = t1;
      }
    }
  }
  c[0][0] = c[0][1] = c[1][1] = 1;
  for (long long i = 2; i <= 2 * n; i++) {
    c[0][i] = 1;
    for (long long j = 1; j <= i; j++)
      c[j][i] = (c[j - 1][i - 1] + c[j][i - 1]) % mod;
  }
  for (long long i = 1; i <= n; i++) {
    vec[g_fa(i)].push_back(i);
  }
  for (long long i = 1; i <= n; i++) {
    if (vec[i].size() > 1) {
      Vec.clear();
      for (long long j = 0; j < vec[i].size(); j++) {
        if (in[vec[i][j]] == 0) Vec.push_back(vec[i][j]);
      }
      long long N = 1 << Vec.size(), cnt = 0;
      memset(g, 0, sizeof g), memset(f, 0, sizeof f);
      for (long long j = 0; j < vec[i].size(); j++) {
        if (in[vec[i][j]]) {
          cnt++;
          for (long long k = 0; k < Vec.size(); k++) {
            if (a[vec[i][j]] % a[Vec[k]] == 0) peach[vec[i][j]] |= 1 << k;
          }
          g[peach[vec[i][j]]]++;
        }
      }
      for (long long j = 0; j < Vec.size(); j++) {
        for (long long k = 0; k < N; k++) {
          if (k >> j & 1) g[k] += g[k - (1 << j)];
        }
      }
      f[0][0] = 1;
      for (long long j = 0; j < N; j++) {
        for (long long k = 0; k <= cnt; k++) {
          if (f[j][k]) {
            if (k < g[j])
              f[j][k + 1] = (f[j][k + 1] + f[j][k] * (g[j] - k) % mod) % mod;
            for (long long p : vec[i]) {
              if (in[p] && ((peach[p] & j) != peach[p]) &&
                  ((peach[p] & j) || j == 0)) {
                f[j | peach[p]][k + 1] =
                    (f[j | peach[p]][k + 1] + f[j][k]) % mod;
              }
            }
          }
        }
      }
      ans = ans * f[N - 1][cnt] % mod * c[cnt - 1][hd + cnt - 1] % mod;
      hd += cnt - 1;
    }
  }
  cout << ans;
}
