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

n,m = f()
a = f()
b = [0]
for i in range(n):
    b.append((b[-1]+a[i])%m)

ans = 0
from collections import Counter
for v in Counter(b).values():
    ans += v*(v-1)//2
print(ans)