import numpy as np
N, M = map(int, input().split(" "))
A = np.array(list(map(int, input().split(" "))))

count = 0
for i in range(len(A)):
    for j in range(i + 1, len(A) + 1):
        if np.sum(A[i:j]) % M == 0:
            count += 1
print(count)
