N, M = map(int, input().split())
A = list(map(int, input().split()))

left = [0 for i in range(N + 1)]
right = [0 for i in range(N + 1)]

for i in range(N):
    left[i + 1] = left[i] + A[i]
for i in range(N)[::-1]:
    right[i] = right[i + 1] + A[i]

res = 0
for l in range(N):
    for r in range(N, l, -1):
        if (left[l] + right[r]) % M == 0:
            res += 1
print(res)