N = int(input()) A = list(map(int,input().split())) C = {} for i in range(N): C[A[i]] = C.get(A[i],0)+1 A = [1]*(N+1) for i in range(2,N+1): A[i] = i*A[i-1] ans = A[N] for i in C: ans //= A[C[i]] print(ans)