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

c = 0
for i in range(n):
    for j in range(i, n):
        s = sum(alist[i:(j+1)])
        if s % m == 0:
            c += 1

print(c)
