import math

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

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

b=[a[0]]

c={}

c[b[0]%m]=1

for i in range(1,n):

  b.append(b[i-1]+a[i])

  c[b[i]%m]=c.get(b[i]%m,0)+1

print((sum([math.factorial(x)//(math.factorial(x-2)*math.factorial(2))if x>1else 0 for x in list(c.values())])+c.get(0,0)))
import math

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

b=0

c={}

for a in input().split():

  b+=int(a)

  c[b%m]=c.get(b%m,0)+1

print((sum([math.factorial(x)//(math.factorial(x-2)*math.factorial(2))if x>1else 0 for x in list(c.values())])+c.get(0,0)))
import math

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [a[0]]
c = {}
c[b[0] % m] = 1
for i in range(1, n):
    b.append(b[i - 1] + a[i])
    c[b[i] % m] = c.get(b[i] % m, 0) + 1
print(
    (
        sum(
            [
                math.factorial(x) // (math.factorial(x - 2) * math.factorial(2))
                if x > 1
                else 0
                for x in list(c.values())
            ]
        )
        + c.get(0, 0)
    )
)

import math

n, m = list(map(int, input().split()))
b = 0
c = {}
for a in input().split():
    b += int(a)
    c[b % m] = c.get(b % m, 0) + 1
print(
    (
        sum(
            [
                math.factorial(x) // (math.factorial(x - 2) * math.factorial(2))
                if x > 1
                else 0
                for x in list(c.values())
            ]
        )
        + c.get(0, 0)
    )
)

-a = list(map(int, input().split())) -b = [a[0]] +b = 0 -c[b[0] % m] = 1 -for i in range(1, n): -    b.append(b[i - 1] + a[i]) -    c[b[i] % m] = c.get(b[i] % m, 0) + 1 +for a in input().split(): +    b += int(a) +    c[b % m] = c.get(b % m, 0) + 1