n,m=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
    A[i]=A[i]%m

B=[]

for i in range(n):
    sumi=A[i]
    ri=i+1
    while ri<n and sumi%m!=0 :
        sumi=(sumi+A[ri])%m
        ri+=1
    if ri==n and sumi%m!=0 :
        ri=-1
    B.append(ri)
#print(B)

mco=0
for i in range(n):
    coi=0
    ms=0
    s=i
    while s!=n and s!=-1 :
        ms=s
        s=B[s]
        B[ms]=-1
        coi+=1
        #print("s"+str(s))
    if s==-1 :
        coi-=1
    #print(coi)
    mco+=coi*(coi+1)//2

print(mco)
