n = int(input()) number = [ int(v) for v in input().split() ] number_list = [ 0 for i in range(100) ] number_list2 = [] for i in number: number_list[i-1] += 1 for i in number_list: if i != 0: number_list2.append(i) n = len(number_list2) s = 0 for i in range(n-2): for j in range(i+1,n-1): for k in range(j+1,n): s += (number_list2[i]*number_list2[j]*number_list2[k]) mod = 10**9+7 print(s%mod)