import numpy as np


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

r = 0
B = A % M
C = np.cumsum(B)

for i in range(len(B)):
    r += sum((C % M) == 0)
    C = C[1:] - C[0]

print(r)