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

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

cnt = 0

for l in range(1, N+1):
    for r in range(l, N+1):
        if sum(A[l:r+1])%M == 0:
            cnt += 1
            
print(cnt)