n,m=map(int,input().split())
if n>100:
    print(w[100])
l=[int(i) for i in input().split()]
w=[0]
for i in l:
    #d.append(i+d[-1])
    w.append((i+w[-1])%m)
ans=0
d={}
for i in w:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
#print(w,d)
for i in d:
    ans+=d[i]*(d[i]-1)
"""
for i in range(n):
    for j in range(i+1,n+1):
        p=abs(d[j]-d[i])
        if p%m==0: ans+=1
"""
print(ans//2)