MOD = 10**9+7 N = int(input()) A = list(map(int,input().split())) C = {} for i in range(N): C[A[i]] = C.get(A[i],0)+1 ans = 0 C = list(C.items()) K = len(C) for i in range(K-2): for j in range(i+1,K-1): for k in range(j+1,K): ans = (ans+C[i][1]*C[j][1]*C[k][1])%MOD print(ans)