import math N = int(input()) l = list(map(int, input().split())) s = set(l) l_count = [] l.sort() old_l_i = 0 count = 0 ans = 0 def combi(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) for l_i in l: if old_l_i == l_i: count += 1 else: l_count.append(count) count = 1 old_l_i = l_i l_count.append(count) l_count = l_count[1:] s = 1 for l_i in l_count: s *= l_i ans = combi(len(l_count), 3) * s print(ans)