f = lambda: list(map(int,input().split()))

n,m = f()
a = f()
a = [sum(a[:i])%m for i in range(n+1)]
ans = 0
from collections import Counter
for v in Counter(a).values():
    ans += v*(v-1)//2
print(ans)