N, M = list(map(int, input().split()))

A = [ int(x) for x in input().split() ]



B = [0]

sum_v = 0



for a in A:

    sum_v += a

    sum_v %= M

    B += [ sum_v ]



B.sort()

B += [ "@" ]



cur = B[0]

cnt, ans = 1, 0



for i, b in enumerate(B):

    if B[i+1] == "@":

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

        break



    if cur == B[i+1]:

        cnt += 1

    else:

        cur = B[i+1]

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

        cnt = 1



print(ans)

N, M = list(map(int, input().split()))

A = [ int(x) for x in input().split() ]



d = {0:1}

ans, s = 0, 0

 

for a in A:

    s += a

    s %= M

    ans += d.get(s, 0)

    d[s] = d.get(s, 0) + 1



print(ans) 

N, M = list(map(int, input().split()))
A = [int(x) for x in input().split()]
B = [0]
sum_v = 0
for a in A:
    sum_v += a
    sum_v %= M
    B += [sum_v]
B.sort()
B += ["@"]
cur = B[0]
cnt, ans = 1, 0
for i, b in enumerate(B):
    if B[i + 1] == "@":
        ans += cnt * (cnt - 1) // 2
        break
    if cur == B[i + 1]:
        cnt += 1
    else:
        cur = B[i + 1]
        ans += cnt * (cnt - 1) // 2
        cnt = 1
print(ans)

N, M = list(map(int, input().split()))
A = [int(x) for x in input().split()]
d = {0: 1}
ans, s = 0, 0
for a in A:
    s += a
    s %= M
    ans += d.get(s, 0)
    d[s] = d.get(s, 0) + 1
print(ans)

-B = [0] -sum_v = 0 +d = {0: 1} +ans, s = 0, 0 -    sum_v += a -    sum_v %= M -    B += [sum_v] -B.sort() -B += ["@"] -cur = B[0] -cnt, ans = 1, 0 -for i, b in enumerate(B): -    if B[i + 1] == "@": -        ans += cnt * (cnt - 1) // 2 -        break -    if cur == B[i + 1]: -        cnt += 1 -    else: -        cur = B[i + 1] -        ans += cnt * (cnt - 1) // 2 -        cnt = 1 +    s += a +    s %= M +    ans += d.get(s, 0) +    d[s] = d.get(s, 0) + 1