import sys from functools import lru_cache input = sys.stdin.buffer.readline sys.setrecursionlimit(4100000) n = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) @lru_cache(None) def calc(bit): # print("bit", bit) if bit == (1 << n) - 1: return 1 res = 0 mx = -1 for i in range(n): if (bit >> i) & 1: mx = max(mx, A[i]) ok = 0 ng = 0 for i in range(n): if (bit >> i) & 1: continue if A[i] >= mx: ok += 1 else: ng += 1 assert ok + ng > 0 # ratio = 1 / (ok + ng) for i in range(n): if (bit >> i) & 1: continue nbit = bit | (1 << i) if A[i] >= mx: res += (ok + ng) * (calc(nbit)) return res cnt = 100 ok = 1 ng = 0 print(calc(0))