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

B = [0 for i in range(N+1)]
for i in range(N):
    B[i+1] = B[i] + A[i]

number = 0

for right in range(1,N+1):
    for left in range(right):
        sum = B[right] - B[left]
        if sum % M == 0:
            number += 1

print(number)
