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

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

b=[0 for x in range(n+1)]

l=list([0])



for i in range(1,n+1):

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



for i in range(1,n+1):

  l.append(b[i]%m)



d=list()

l.sort()

t,c=0,1

for i in range(1,n+1):

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

    c+=1

  else:

    if c!=1:

      t += c*(c-1)//2

      c=1



if c!=1:

  t += c*(c-1)//2  



print(t)

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

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

l=list([0])



b=0

for i in range(0,n):

  b += a[i]

  l.append(b%m)

l.append(m)



l.sort()

t,c=0,1

for i in range(1,n+2):

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

    c+=1

  else:

    if c!=1:

      t += c*(c-1)//2

      c=1

print(t)

n, m = list(map(int, input().split()))
a = [int(x) for x in input().split()]
b = [0 for x in range(n + 1)]
l = list([0])
for i in range(1, n + 1):
    b[i] = b[i - 1] + a[i - 1]
for i in range(1, n + 1):
    l.append(b[i] % m)
d = list()
l.sort()
t, c = 0, 1
for i in range(1, n + 1):
    if l[i] == l[i - 1]:
        c += 1
    else:
        if c != 1:
            t += c * (c - 1) // 2
            c = 1
if c != 1:
    t += c * (c - 1) // 2
print(t)

n, m = list(map(int, input().split()))
a = [int(x) for x in input().split()]
l = list([0])
b = 0
for i in range(0, n):
    b += a[i]
    l.append(b % m)
l.append(m)
l.sort()
t, c = 0, 1
for i in range(1, n + 2):
    if l[i] == l[i - 1]:
        c += 1
    else:
        if c != 1:
            t += c * (c - 1) // 2
            c = 1
print(t)

-b = [0 for x in range(n + 1)] -for i in range(1, n + 1): -    b[i] = b[i - 1] + a[i - 1] -for i in range(1, n + 1): -    l.append(b[i] % m) -d = list() +b = 0 +for i in range(0, n): +    b += a[i] +    l.append(b % m) +l.append(m) -for i in range(1, n + 1): +for i in range(1, n + 2): -if c != 1: -    t += c * (c - 1) // 2