#include <bits/stdc++.h>
using namespace std;
long long n, m, p;
long long a[65], C[65][65], f[65][1 << 18], b[65], dem[1 << 18], fac[65],
    vis[65];
int main() {
  cin >> n;
  fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
  }
  for (int i = 0; i <= n; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;
    }
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      long long flag = 0;
      vis[i] = m;
      for (int j = i + 1; j <= n; j++) {
        if (a[j] % a[i] == 0) {
          vis[j] = -1;
          b[j] |= 1 << vis[i];
          flag = 1;
        }
      }
      if (flag)
        m++;
      else {
        vis[i] = -2;
        p++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == -1) {
      dem[b[i]]++;
    }
  }
  for (int i = (1 << m) - 1; i >= 0; i--) {
    for (int j = i; j; j = (j - 1) & i) {
      dem[i] += dem[i ^ j];
    }
  }
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == -1) {
      for (int j = i - 1; j >= 0; j--) {
        for (int k = 0; k < 1 << m; k++) {
          (f[j + 1][k | b[i]] += f[j][k]) %= 1000000007;
        }
      }
    }
  }
  for (int i = 0; i <= n - m - p; i++) {
    for (int j = 0; j < 1 << m; j++) {
      if (f[i][j]) {
        (f[i][j] *= fac[dem[j] - i] * C[n - m - p - i][dem[j] - i] %
                    1000000007) %= 1000000007;
      }
    }
    for (int j = 0; j < 1 << m; j++) {
      for (int k = 1; k <= n; k++) {
        if (vis[k] == -1 && (b[k] & j) != 0 && (b[k] | j) != j) {
          (f[i][j | b[k]] +=
           f[i][j] * C[n - m - p - dem[j] - 1][dem[j | b[k]] - dem[j] - 1] %
           1000000007 * fac[dem[j | b[k]] - dem[j] - 1]) %= 1000000007;
        }
      }
    }
    if (f[i][(1 << m) - 1]) {
      cout << f[i][(1 << m) - 1];
      return 0;
    }
  }
}
