n,m=map(int,input().split())
a=list(map(int,input().split()))

cnt=0
dic={}
aaa=0
zero=0
for aa in a:
    aaa+=aa
    amod=aa%m
    if amod==0:
        cnt+=1
        zero+=1
    
    if (m-amod)%m in dic:
        cnt+=dic[(m-amod)%m]
    
    if aaa%m in dic:
        dic[aaa%m]+=1+zero
    else:
        dic[aaa%m]=1+zero
    #print(aaa,aa,aaa%m,dic)
print(cnt)

