#include <bits/stdc++.h>   using std::max;   using std::min;   const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;   const long long INF = 0x3f3f3f3f3f3f3f3f;   __inline__ __attribute__((always_inline)) unsigned int rnd() {     static unsigned int seed = 416;     return seed += 0x71dad4bfu, seed ^= seed >> 5, seed += 0xc6f74d88u,            seed ^= seed << 17, seed += 0x25e6561u, seed ^= seed >> 13;   }   template <typename _Tp>   _Tp gcd(const _Tp &a, const _Tp &b) {     return (!b) ? a : gcd(b, a % b);   }   template <typename _Tp>   __inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {     return a >= 0 ? a : -a;   }   template <typename _Tp>   __inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {     (a < b) && (a = b);   }   template <typename _Tp>   __inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {     (b < a) && (a = b);   }   template <typename _Tp>   __inline__ __attribute__((always_inline)) void read(_Tp &x) {     char ch(getchar());     bool f(false);     while (!isdigit(ch)) f |= ch == 45, ch = getchar();     x = ch & 15, ch = getchar();     while (isdigit(ch)) x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();     f && (x = -x);   }   template <typename _Tp, typename... Args>   __inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {     read(t);     read(args...);   }   template <typename _Tp, typename... Args>   __inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b,                                                     const Args &...args) {     return a < b ? min(a, args...) : min(b, args...);   }   template <typename _Tp, typename... Args>   __inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b,                                                     const Args &...args) {     return a < b ? max(b, args...) : max(a, args...);   }   __inline__ __attribute__((always_inline)) int read_str(char *s) {     char ch(getchar());     while (ch ==     || ch ==   r  || ch ==   n ) ch = getchar();     char *tar = s;     *tar = ch, ch = getchar();     while (ch !=     && ch !=   r  && ch !=   n  && ch != EOF)       *(++tar) = ch, ch = getchar();     return tar - s + 1;   }   const int N = 65;   const int mod = 1000000007;   template <typename _Tp1, typename _Tp2>   __inline__ __attribute__((always_inline)) void add(_Tp1 &a, _Tp2 b) {     (a += b) >= mod && (a -= mod);   }   template <typename _Tp1, typename _Tp2>   __inline__ __attribute__((always_inline)) void sub(_Tp1 &a, _Tp2 b) {     (a -= b) < 0 && (a += mod);   }   int n, a[N], fa[N];   int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }   int dp[1 << 15][N], sum[1 << 15];   std::pair<int, int> solve(int ___) {     std::vector<int> nd;     for (int i = 1; i <= n; ++i)       if (find(i) == ___) nd.push_back(a[i]);     std::vector<int> A, B;     for (auto a : nd) {       int cnt = 0;       for (auto b : nd)         if (a != b && !(a % b)) ++cnt;       if (!cnt)         A.push_back(a);       else         B.push_back(a);     }     if (((int)B.size()) <= 1) return std::make_pair(0, 1);     memset(dp, 0, sizeof(dp));     memset(sum, 0, sizeof(sum));     for (auto &&it : B) {       int qwq = 0;       for (int i = 0; i < ((int)A.size()); ++i)         if (!(it % A[i])) qwq |= 1 << i;       it = qwq, ++sum[it];       ++dp[it][1];     }     for (int i = 0; i < ((int)A.size()); ++i)       for (int st = 0; st < 1 << ((int)A.size()); ++st)         if ((st >> i) & 1) sum[st] += sum[st ^ (1 << i)];     for (int st = 0; st < 1 << ((int)A.size()); ++st) {       for (int j = 1; j <= ((int)B.size()); ++j) {         if (!dp[st][j]) continue;         add(dp[st][j + 1], 1ll * dp[st][j] * (sum[st] - j) % mod);         for (auto it : B)           if ((it & st) && (st & it) != it) add(dp[st | it][j + 1], dp[st][j]);       }     }     return std::make_pair(((int)B.size()) - 1,                           dp[(1 << ((int)A.size())) - 1][((int)B.size())]);   }   int C[N][N];   int main() {     for (int i = 0; i < N; ++i)       for (int j = C[i][0] = 1; j <= i; ++j)         C[i][j] = C[i - 1][j - 1], add(C[i][j], C[i - 1][j]);     read(n);     for (int i = 1; i <= n; ++i) read(a[i]), fa[i] = i;     std::sort(a + 1, a + n + 1);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         if (!(a[i] % a[j])) fa[find(i)] = find(j);     long long ans = 1, res = 0;     for (int i = 1; i <= n; ++i) {       if (fa[i] == i) {         std::pair<int, int> tmp = solve(i);         res += tmp.first;         ans = ans * C[res][tmp.first] % mod * tmp.second % mod;       }     }     printf( %lld n , ans);     return 0;   }