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

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

s = 0
count = 0

for l in range(n):
    for r in range(n):
        s = sum(a[l:r+1])
        if s % m == 0:
            count += 1

print(int(count/2))
