from itertools import combinations as comb N = input() A = map(int,raw_input().split()) V = [0]*(100) for a in A: V[a-1] += 1 print sum(x*y*z for x,y,z in comb(V,3)) % (10**9+7)