n = int(input()) A = list(map(int, input().split())) cnt = 0 dp = [0] * (1 << n) max_ = [0] * (1 << n) dp[0] = 1 for bit in range(1, 1 << n): for i in range(n): if bit >> i & 1: bbit = bit ^ (1 << i) if A[i] >= max_[bbit]: max_[bbit] = A[i] dp[bit] += dp[bbit] x = dp[-1] ans = 1 for i in range(1, n + 1): ans *= i print(ans // x)