n = int(input()) A = list(map(int, input().split())) F = [1 for _ in range(n + 1)] for i in range(2, n + 1): F[i] = i * F[i - 1] A.sort() ans = F[n] cnt = 1 for i in range(1, n): if A[i] == A[i - 1]: cnt += 1 if i == n - 1: ans //= F[cnt] else: ans //= F[cnt] cnt = 1 print(ans)