from collections import Counter
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[0]
for i in range(n):
    b.append((a[i]+b[-1])%m)
b2=Counter(b)
ans=0
for i,j in b2.most_common():
    if j>1: ans+=j*(j-1)//2
print(ans)