# 105 D
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
#print(N,M)#
#print(A)#
c = 0
for l in range(N):
    sm = 0
    for r in range(l, N):
        sm += A[r]
        #sm = sum(A[l:r+1])
        #print(sm)#
        if sm%M == 0: c += 1
print(c)