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

_A=[sum(A[:i:]) for i in range(N+1)]
print(_A)
count=0
for l in range(N+1):
    for r in range(l+1,N+1):

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


print(count)
