from collections import *
n, m = map(int, input().split())
a = list(map(int, input().split()))
c = Counter()
v = 0
for e in a:
    v += e
    v %= m
    c[v] += 1
v = r = 0
for e in a:
    r += c[v]
    v += e
    v %= m
    c[v] -= 1
print(r)