def RunLengthEncoding(S): res = [] N = len(S) i = 0 while i < N: cnt = 1 while i < N - 1 and S[i] == S[i + 1]: cnt += 1 i += 1 res.append(cnt) i += 1 return res N = int(input()) A = list(map(int, input().split())) A.sort() RLE = RunLengthEncoding(A) fact = [1] * (N + 1) for i in range(1, N+1): fact[i] = fact[i-1] * i ok = 1 for i in RLE: ok *= fact[i] print(fact[N] // ok)