from itertools import accumulate

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

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

acc = [0] + list(accumulate(a))

mod = {}

for i in acc:

    d = i%m

    if d not in mod:

        mod[d] = 0

    mod[d] += 1

cnt = 0

for v in list(mod.values()):

    if v:

        cnt += v * (v-1) // 2

print(cnt)

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

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

from itertools import accumulate

acc = [0] + [i % m for i in accumulate(a)]

from collections import Counter

ans = sum([v * (v-1) // 2 for v in list(Counter(acc).values())])

print(ans)
from itertools import accumulate

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
acc = [0] + list(accumulate(a))
mod = {}
for i in acc:
    d = i % m
    if d not in mod:
        mod[d] = 0
    mod[d] += 1
cnt = 0
for v in list(mod.values()):
    if v:
        cnt += v * (v - 1) // 2
print(cnt)

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
from itertools import accumulate

acc = [0] + [i % m for i in accumulate(a)]
from collections import Counter

ans = sum([v * (v - 1) // 2 for v in list(Counter(acc).values())])
print(ans)

+n, m = list(map(int, input().split())) +a = list(map(int, input().split())) -n, m = list(map(int, input().split())) -a = list(map(int, input().split())) -acc = [0] + list(accumulate(a)) -mod = {} -for i in acc: -    d = i % m -    if d not in mod: -        mod[d] = 0 -    mod[d] += 1 -cnt = 0 -for v in list(mod.values()): -    if v: -        cnt += v * (v - 1) // 2 -print(cnt) +acc = [0] + [i % m for i in accumulate(a)] +from collections import Counter + +ans = sum([v * (v - 1) // 2 for v in list(Counter(acc).values())]) +print(ans)