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

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

counter = 0
for i in range(0, n+1):
    for j in range(i+1, n+1):
        if s[i] == s[j]:
            counter += 1
print(counter)