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