#include <bits/stdc++.h>
using namespace std;
int a[60], s[61], b[60];
long long int adj[60];
int visited[60];
vector<int> cc;
int doDFS(int u) {
  if (visited[u]) return 0;
  int i;
  visited[u] = 1, cc.push_back(u);
  for (i = 0; i < 60; i++) {
    if (adj[u] & (1LL << i)) doDFS(i);
  }
  return 0;
}
int C[61][61];
map<long long int, int> dp[61];
int main() {
  int i;
  int n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int j, k;
  int m = 0;
  for (i = 0; i < n; i++) {
    if (!s[a[i]]) {
      for (j = 2 * a[i]; j <= 60; j += a[i]) s[j] = 1;
    } else
      b[m++] = a[i];
  }
  for (i = 0; i < m; i++) {
    adj[i] |= (1LL << i);
    for (j = i + 1; j < m; j++) {
      for (k = 0; k < n; k++) {
        if (((b[i] % a[k]) == 0) && ((b[j] % a[k]) == 0)) break;
      }
      if (k < n) adj[i] |= (1LL << j), adj[j] |= (1LL << i);
    }
  }
  int ans = 1, sum = 0;
  for (i = 0; i <= m; i++) {
    C[i][0] = 1;
    for (j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;
  }
  for (i = 0; i < m; i++) {
    if (!visited[i]) {
      doDFS(i);
      for (j = 0; j < cc.size(); j++) dp[1][adj[cc[j]]]++;
      for (j = 1; j < cc.size(); j++) {
        for (auto it = dp[j].begin(); it != dp[j].end(); it++) {
          int c = 0;
          for (k = 0; k < cc.size(); k++) {
            if (it->first & (1LL << cc[k])) {
              if ((it->first | adj[cc[k]]) != it->first) {
                dp[j + 1][it->first | adj[cc[k]]] += it->second;
                if (dp[j + 1][it->first | adj[cc[k]]] >= 1000000007)
                  dp[j + 1][it->first | adj[cc[k]]] -= 1000000007;
              } else
                c++;
            }
          }
          if (c > j)
            dp[j + 1][it->first] =
                (dp[j + 1][it->first] + (long long int)it->second * (c - j)) %
                1000000007;
        }
      }
      ans = ((long long int)ans * dp[cc.size()].begin()->second) % 1000000007;
      ans = ((long long int)ans * C[sum + cc.size() - 1][cc.size() - 1]) %
            1000000007;
      sum += cc.size() - 1;
      for (j = 1; j <= cc.size(); j++) dp[j].clear();
      cc.clear();
    }
  }
  printf("%d\n", ans);
  return 0;
}
