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