from itertools import accumulate

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

A.insert(0, 0)
a = list(accumulate(A))
ans = 0

for i in range(0, N):
    for j in range(i+1, N+1):
        if (a[j] - a[i])%M == 0:
            ans += 1
print(ans) 