import itertools

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

acc = [0] + list(itertools.accumulate(A))

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