import collections

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

A = [int(i)%M for i in input().split()]

B = [0]

sum_ = 0

for a in A:

    sum_ = (sum_ + a) % M

    B.append(sum_)

b = collections.Counter(B)

ans = 0

for c in list(b.values()):

    ans += int(c * (c - 1) / 2)

print(ans)
from collections import  Counter

from itertools import accumulate



from operator import add, mul

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

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

ans=0

b= list(accumulate(a, add))

b=list([x%m for x in b])

c=Counter(b)

c[0]=c[0]+1

ans=0

for i in list(c.values()):

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

print(ans)

import collections

N, M = list(map(int, input().split()))
A = [int(i) % M for i in input().split()]
B = [0]
sum_ = 0
for a in A:
    sum_ = (sum_ + a) % M
    B.append(sum_)
b = collections.Counter(B)
ans = 0
for c in list(b.values()):
    ans += int(c * (c - 1) / 2)
print(ans)

from collections import Counter
from itertools import accumulate
from operator import add, mul

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
b = list(accumulate(a, add))
b = list([x % m for x in b])
c = Counter(b)
c[0] = c[0] + 1
ans = 0
for i in list(c.values()):
    ans += i * (i - 1) // 2
print(ans)

-import collections +from collections import Counter +from itertools import accumulate +from operator import add, mul -N, M = list(map(int, input().split())) -A = [int(i) % M for i in input().split()] -B = [0] -sum_ = 0 -for a in A: -    sum_ = (sum_ + a) % M -    B.append(sum_) -b = collections.Counter(B) +n, m = list(map(int, input().split())) +a = list(map(int, input().split())) -for c in list(b.values()): -    ans += int(c * (c - 1) / 2) +b = list(accumulate(a, add)) +b = list([x % m for x in b]) +c = Counter(b) +c[0] = c[0] + 1 +ans = 0 +for i in list(c.values()): +    ans += i * (i - 1) // 2