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

t = 0
s = [0 for _ in range(len(a)+1)]
for i in range(len(a)):
    s[i+1] = a[i] + t
    t += a[i]

counter = 0
for i in range(1, len(s)+1):
    for j in range(n-i+1):
        if (s[j+i] - s[j]) % m == 0:
            counter += 1

print(counter)
