cnt = [0] * 101 N = int(input()) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 for i in range(N): cnt[A[i]] += 1 ans = 0 for i in range(1, 101): for j in range(i + 1, 101): for k in range(j + 1, 101): ans = (ans + cnt[i] * cnt[j] * cnt[k]) % MOD print(ans)