import time
import numpy as np

N,M=map(int,input().split())
A=list(map(int,input().split()))

time1=time.time()


S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2

time2=time.time()
countlist=np.zeros(M)
check=set()

time3=time.time()

for i in range(1,N+1):
    countlist[S[i]]+=1
    check=check|{S[i]}
    
    

time4=time.time()



ANS=countlist[0]

for i in check:
    ANS+=tr(countlist[i])



print(int(ANS))




