n, m = map(int, input().split())
lst = list(map(int, input().split()))
ans = 0

for i in range(n):
    total = 0
    for j in range(i, n):
        total += lst[j]
        if total%m==0:
            ans += 1
print(ans)