from collections import Counter

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

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



ctr = Counter()

ctr[0] = 1



cum = 0

for a in A:

    cum = (cum + a) % M

    ctr[cum] += 1



ans = 0

for v in list(ctr.values()):

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

print(ans)
from collections import Counter



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

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



cums = [0]

for a in A:

    cums.append((cums[-1] + a) % M)



ctr = Counter(cums)



ans = 0

for v in list(ctr.values()):

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

print(ans)
from collections import Counter

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
ctr = Counter()
ctr[0] = 1
cum = 0
for a in A:
    cum = (cum + a) % M
    ctr[cum] += 1
ans = 0
for v in list(ctr.values()):
    ans += v * (v - 1) // 2
print(ans)

from collections import Counter

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
cums = [0]
for a in A:
    cums.append((cums[-1] + a) % M)
ctr = Counter(cums)
ans = 0
for v in list(ctr.values()):
    ans += v * (v - 1) // 2
print(ans)

-ctr = Counter() -ctr[0] = 1 -cum = 0 +cums = [0] -    cum = (cum + a) % M -    ctr[cum] += 1 +    cums.append((cums[-1] + a) % M) +ctr = Counter(cums)