from collections import defaultdict from itertools import combinations N = int(input()) take = defaultdict(lambda: 0) devider = 10**9 + 7 for i in [i for i in input().split()]: take[i] += 1 s_1 = sum([v for v in take.values()]) s_2 = sum([v**2 for v in take.values()]) s_3 = sum([v**3 for v in take.values()]) res = (s_1**3 - 3*s_1*s_2 + 2*s_3) // 6 print(res)