N,M=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]

_A=[sum(A[:i+1:]) for i in range(N)]

count=0
for l in range(N):
    for r in range(l,N):

            if (_A[r]-_A[l-1])%M==0:
                count+=1


print(count)
