from collections import Counter


N = int(input())
A = list(map(int, input().split()))

cnt: Counter[int] = Counter()

for i in range(N):
    cnt[A[i]] += 1


def combination(n: int, r: int) -> int:
    y = 1
    x = 1
    for i in range(r):
        y *= n - i
        x *= i + 1
    return y // x


ans = 0
for a in cnt:
    ans += combination(cnt[a], 3)

print(ans)
