N, M = [int(v) for v in input().split()]
A = [int(v) for v in input().split()]
for i in range(1, N):
    A[i] += A[i - 1]

ans = 0
for l in range(N):
    for r in range(l, N):
        if l <= 0:
            lc = 0
        else:
            lc = A[l - 1]
        cnt = A[r] - lc
        if cnt % M == 0:
            ans += 1
print(ans)