n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[0]*(n+1)
for i in range(n):
    l[i]+=a[i]
    l[i+1]+=l[i]
c=0
for i in range(n):
    for j in range(i,n):
        if i==0:
            if l[j]%m==0:c+=1
        else:
            if (l[j]-l[i-1])%m==0:c+=1
print(c)