import itertools n = int(input()) a = list(map(int, input().split())) d = [0 for _ in range(max(a)+1)] set_a = set(a) mod = 10 ** 9 + 7 for i in set_a: d[i] = a.count(i) ans = 0 for c in itertools.combinations(set_a, 3): ans += d[c[0]] * d[c[1]] * d[c[2]] % mod print(ans)