N = int(input()) A = [0] * 100 for a in map(int, input().split()): A[a - 1] += 1 ans = 0 mod = 10 ** 9 + 7 for i in range(100): for j in range(i): for k in range(j): ans += A[i] * A[j] * A[k] ans %= mod print(ans)