from itertools import accumulate

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

Ac = list(accumulate(A))
answer = len(list(filter(lambda x: x % M == 0, Ac)))

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

print(answer)