# coding: utf-8

n, m = map(int, input().split())
a = list(map(int, input().split()))

count = 0

for begin in range(n):
    for end in range(begin+1, n+1):
        if sum(a[begin:end]) % m == 0:
            count += 1

print(count)
