N, M = (int (i) for i in input().split())
A = [int (i) for i in input().split()]

ans = 0

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

print(ans)