N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
hash = {}
hash[0] = 1
i = 0
for a in A:
    i = (i+a) % M
    if i in list(hash.keys()):
        hash[i] += 1
    else:
        hash[i] = 1
for h in list(hash.keys()):
    ans += hash[h] * (hash[h]-1) // 2

print(ans)