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

sum = 0
counter = 0

for i in range(N):
    sum = 0
    for s in range(i, N):
        # print("A[s]= " + str(A[s]))
        sum += A[s]
        # print(sum)

        if sum % M == 0:
            counter += 1
            # print("+")

print(counter)