def f(m):

    aa = [int(ak) % m for ak in input().split()]

    mod = {}

    ans = 0

    zi = 0

    for a in aa:

        mod.setdefault(zi, 0)

        mod[zi] += 1

        zi = (zi - a) % m

        ans += mod.get(zi, 0)

    print(ans)





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

f(m)

from itertools import accumulate

from collections import Counter



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

ans = sum(v * (v - 1) // 2 for v in list(Counter([ak % m for ak in accumulate(list(map(int, input().split())))] + [0]).values()))

print(ans)

def f(m):
    aa = [int(ak) % m for ak in input().split()]
    mod = {}
    ans = 0
    zi = 0
    for a in aa:
        mod.setdefault(zi, 0)
        mod[zi] += 1
        zi = (zi - a) % m
        ans += mod.get(zi, 0)
    print(ans)


_, m = list(map(int, input().split()))
f(m)

from itertools import accumulate
from collections import Counter

n, m = list(map(int, input().split()))
ans = sum(
    v * (v - 1) // 2
    for v in list(
        Counter(
            [ak % m for ak in accumulate(list(map(int, input().split())))] + [0]
        ).values()
    )
)
print(ans)

-def f(m): -    aa = [int(ak) % m for ak in input().split()] -    mod = {} -    ans = 0 -    zi = 0 -    for a in aa: -        mod.setdefault(zi, 0) -        mod[zi] += 1 -        zi = (zi - a) % m -        ans += mod.get(zi, 0) -    print(ans) +from itertools import accumulate +from collections import Counter - -_, m = list(map(int, input().split())) -f(m) +n, m = list(map(int, input().split())) +ans = sum( +    v * (v - 1) // 2 +    for v in list( +        Counter( +            [ak % m for ak in accumulate(list(map(int, input().split())))] + [0] +        ).values() +    ) +) +print(ans)