from collections import Counter

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

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

acc = 0

acc_alst = []

for a in alst:

  acc += a

  acc %= m

  acc_alst.append(acc)



count = Counter(acc_alst)

ans = 0

for k, v in list(count.items()):

  if k == 0:

    ans += v

  if v >= 2:

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

print(ans)
from collections import Counter as C

from itertools import accumulate as a

def inp():return list(map(int,input().split()))

n,m = inp()

print((sum([v*(v-1)//2+(0 if k else v)for k,v in list(C([x%m for x in a(inp())]).items())])))
from collections import Counter

n, m = list(map(int, input().split()))
alst = list(map(int, input().split()))
acc = 0
acc_alst = []
for a in alst:
    acc += a
    acc %= m
    acc_alst.append(acc)
count = Counter(acc_alst)
ans = 0
for k, v in list(count.items()):
    if k == 0:
        ans += v
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

from collections import Counter as C
from itertools import accumulate as a


def inp():
    return list(map(int, input().split()))


n, m = inp()
print(
    (
        sum(
            [
                v * (v - 1) // 2 + (0 if k else v)
                for k, v in list(C([x % m for x in a(inp())]).items())
            ]
        )
    )
)

-from collections import Counter +from collections import Counter as C +from itertools import accumulate as a -n, m = list(map(int, input().split())) -alst = list(map(int, input().split())) -acc = 0 -acc_alst = [] -for a in alst: -    acc += a -    acc %= m -    acc_alst.append(acc) -count = Counter(acc_alst) -ans = 0 -for k, v in list(count.items()): -    if k == 0: -        ans += v -    if v >= 2: -        ans += v * (v - 1) // 2 -print(ans) + +def inp(): +    return list(map(int, input().split())) + + +n, m = inp() +print( +    ( +        sum( +            [ +                v * (v - 1) // 2 + (0 if k else v) +                for k, v in list(C([x % m for x in a(inp())]).items()) +            ] +        ) +    ) +)