n, m = map(int, input().split())
a = list( map(int, input().split()))
a_modm=[ai%m for ai in a]

from itertools import accumulate
B = [0] + a_modm
B = list(accumulate(B))
ans = 0
for i in range(0,n):
    for j in range(i,n):
        if (B[j+1]-B[i])%m == 0:
            ans+=1

print(ans)
