n = input() a = map(int, raw_input().split()) a.sort() num = [0] * 101 for x in a: num[x] += 1 ans = 0 for i in xrange(101): for j in xrange(i + 1, 101): for k in xrange(j + 1, 101): ans += num[i] * num[j] * num[k] mod = 10 ** 9 + 7 ans %= mod print ans