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

from itertools import accumulate

xs = list(accumulate(A)) + [0]

result = 0

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

print(result)

