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