n, m = [int(i) for i in input().split()]
a = [int(i)%m for i in input().split()]

c = 0
b = 0
for l in range(n):
    b += a[l]
    for r in range(l, n):
        if l != r:
            b += a[r]
        if b % m == 0:
            c += 1
    b = 0

print(c)

