N=int(input()) A=list(map(int,input().split())) from collections import Counter C=Counter(A) L=list(C.keys()) ANS=0 for i in range(len(L)): for j in range(i+1,len(L)): for k in range(j+1,len(L)): ANS+=C[L[i]]*C[L[j]]*C[L[k]] print(ANS%(10**9+7))