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

*a, = list(map(int, input().split()))



b = 0

c = {0: 1}

cnt = 0

for a in a:

    b = (b + a) % m

    cnt += c.get(b, 0)

    c[b] = c.get(b, 0) + 1

print(cnt)
from collections import defaultdict





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

*a, = list(map(int, input().split()))



b = 0

c = defaultdict(int)

c[0] = 1

cnt = 0

for a in a:

    b = (b + a) % m

    cnt += c[b]

    c[b] = c[b] + 1

print(cnt)
n, m = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
b = 0
c = {0: 1}
cnt = 0
for a in a:
    b = (b + a) % m
    cnt += c.get(b, 0)
    c[b] = c.get(b, 0) + 1
print(cnt)

from collections import defaultdict

n, m = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
b = 0
c = defaultdict(int)
c[0] = 1
cnt = 0
for a in a:
    b = (b + a) % m
    cnt += c[b]
    c[b] = c[b] + 1
print(cnt)

+from collections import defaultdict + -c = {0: 1} +c = defaultdict(int) +c[0] = 1 -    cnt += c.get(b, 0) -    c[b] = c.get(b, 0) + 1 +    cnt += c[b] +    c[b] = c[b] + 1