import numpy as np

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

a = np.array(list(map(int, input().split()))).astype("int64") 

a = np.cumsum(a)

a %= m

count = np.sum(a == 0)

a.sort()

tc = 1

for i in range(1, n):

    if a[i - 1] == a[i]:

        tc += 1

    else:

        count += tc * (tc - 1) // 2

        tc = 1

else:

    count += tc * (tc - 1) // 2

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

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

unique_a = {a[0] % m: 1}

for i in range(1, n):

    a[i] += a[i - 1]

    a[i] %= m

    if a[i] in unique_a:

        unique_a[a[i]] += 1

    else:

        unique_a[a[i]] = 1

count = 0

if 0 in unique_a:

    count += unique_a[0]

for k in unique_a:

    count += unique_a[k] * (unique_a[k] - 1) // 2

print(count)
import numpy as np

(n, m) = list(map(int, input().split()))
a = np.array(list(map(int, input().split()))).astype("int64")
a = np.cumsum(a)
a %= m
count = np.sum(a == 0)
a.sort()
tc = 1
for i in range(1, n):
    if a[i - 1] == a[i]:
        tc += 1
    else:
        count += tc * (tc - 1) // 2
        tc = 1
else:
    count += tc * (tc - 1) // 2
print(count)

(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
unique_a = {a[0] % m: 1}
for i in range(1, n):
    a[i] += a[i - 1]
    a[i] %= m
    if a[i] in unique_a:
        unique_a[a[i]] += 1
    else:
        unique_a[a[i]] = 1
count = 0
if 0 in unique_a:
    count += unique_a[0]
for k in unique_a:
    count += unique_a[k] * (unique_a[k] - 1) // 2
print(count)

-import numpy as np - -a = np.array(list(map(int, input().split()))).astype("int64") -a = np.cumsum(a) -a %= m -count = np.sum(a == 0) -a.sort() -tc = 1 +a = list(map(int, input().split())) +unique_a = {a[0] % m: 1} -    if a[i - 1] == a[i]: -        tc += 1 +    a[i] += a[i - 1] +    a[i] %= m +    if a[i] in unique_a: +        unique_a[a[i]] += 1 -        count += tc * (tc - 1) // 2 -        tc = 1 -else: -    count += tc * (tc - 1) // 2 +        unique_a[a[i]] = 1 +count = 0 +if 0 in unique_a: +    count += unique_a[0] +for k in unique_a: +    count += unique_a[k] * (unique_a[k] - 1) // 2