N, M = [int(n) for n in input().split()]
As = [int(n) for n in input().split()]

Ass = [0]

for i in range(N):
    Ass.append(As[i] + Ass[i])

c = 0
for l in range(N):
    for r in range(l + 1, N + 1):
        c += 1 if (Ass[r] - Ass[l]) % M == 0 else 0

print(c)
