import itertools

n, m = map(int, input().split())
a=list(map(int,input().split()))
b =[0]+ list(itertools.accumulate(a))
count=0

for i in range(n):
    for j in range(i+1,n+1):
        if (b[j]-b[i])%m==0:
            count+=1
print(count)
