from collections import defaultdict
N,M=list(map(int, input().strip().split()))
A=list(map(int, input().strip().split()))
AS=[0]*N
AS[0]=A[0]%M
modG=defaultdict(list)
ct=0
for i in range(1,N):
    AS[i]=(AS[i-1]+A[i])%M
for i,a in enumerate(AS):
    if a==0:ct+=1
    modG[a].append(i)
for i in range(N):
    for x in modG[AS[i]]:
        if x+1>i:break
        ct+=1
print(ct)