from collections import defaultdict

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

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

A[0] %= M

for i in range(N-1):

    A[i+1] += A[i]

    A[i+1] %= M

d = defaultdict(lambda:0)

d[0] = 1

ans = 0

for i in range(N):

    ans += d[A[i]]

    d[A[i]] += 1

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

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

from collections import defaultdict

r = defaultdict(lambda:0)



s = 0

for i in range(N):

    s += A[i]

    s %= M

    r[s] += 1



ans = r[0]

for s in r:

    ans += (r[s]*(r[s]-1))//2



print(ans)
from collections import defaultdict

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A[0] %= M
for i in range(N - 1):
    A[i + 1] += A[i]
    A[i + 1] %= M
d = defaultdict(lambda: 0)
d[0] = 1
ans = 0
for i in range(N):
    ans += d[A[i]]
    d[A[i]] += 1
print(ans)

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
from collections import defaultdict

r = defaultdict(lambda: 0)
s = 0
for i in range(N):
    s += A[i]
    s %= M
    r[s] += 1
ans = r[0]
for s in r:
    ans += (r[s] * (r[s] - 1)) // 2
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())) -A[0] %= M -for i in range(N - 1): -    A[i + 1] += A[i] -    A[i + 1] %= M -d = defaultdict(lambda: 0) -d[0] = 1 -ans = 0 +r = defaultdict(lambda: 0) +s = 0 -    ans += d[A[i]] -    d[A[i]] += 1 +    s += A[i] +    s %= M +    r[s] += 1 +ans = r[0] +for s in r: +    ans += (r[s] * (r[s] - 1)) // 2