import numpy as np


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

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

for i in range(len(A)):
    r += np.sum((A[i:] % M) == 0)
    A  = A - A[i]

print(r)