n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
sum=0
alist=[]
for i in a:
    sum+=i
    alist.append(sum%m)
alist.sort()
k=-1
n=0
for j in alist:
    n+=1
    if k!=j:
        count+=(n*(n-1)/2)
        n=0
    k=j
count+=(n*(n-1)/2)
print(int(count))