import numpy as np


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

r = 0
B = A % M

for i in range(len(B)):
    r += sum((np.cumsum(B) % M) == 0)
    B = B[1:]

print(r)