n = int(input()) A = list(map(int, input().split())) mod = 10**9 + 7 fact = [1] * (n + 1) inv = [1] * (n + 1) finv = [1] * (n + 1) for i in range(2, n + 1): fact[i] = fact[i - 1] * i % mod inv[i] = mod - inv[mod % i] * (mod // i) % mod finv[i] = finv[i - 1] * inv[i] % mod C = [0 for _ in range(101)] for i in range(n): C[A[i]] += 1 ans = 0 for x in range(1, 101): xx = C[x] for y in range(x + 1, 101): yy = C[y] for z in range(y + 1, 101): zz = C[z] ans += xx * yy % mod * zz % mod ans %= mod print(ans)