N = int(input()) A = list(map(int,input().split())) A.sort() dict = {} for i,v in enumerate(A): if v not in dict: dict[v] = 1 else: dict[v]+=1 bunbo = 1 bunshi = 1 nokori = N for i,v in enumerate(A): if dict[v] == 1: bunbo*=nokori bunshi*=1 nokori-=1 else: bunbo*=nokori bunshi*=dict[v] dict[v]-=1 nokori-=1 ans = bunbo//bunshi print(ans)