N, M = map(int, input().split())
As = list(map(int, input().split()))
ans = 0
for l in range(N):
    tmp = 0
    for r in range(l, N):
        tmp += As[r]
        if tmp % M == 0:
            ans += 1
print(ans)