

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

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









S=[0]*(N+1)

for i in range(N):

    S[i+1]=(A[i]+S[i])%M





def tr(k):

    return k*(k-1)//2



S.sort()

S=[-1]+S+[-1]

count=0

ANS=0



for i in range(1,N+3):

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

        count+=1

    else:

        ANS+=tr(count)

        count=1



print(ANS)

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

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



SUM=[0]

for a in A:

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



from collections import Counter

counter=Counter(SUM)



ANS=0

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

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



print(ANS)
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
S = [0] * (N + 1)
for i in range(N):
    S[i + 1] = (A[i] + S[i]) % M


def tr(k):
    return k * (k - 1) // 2


S.sort()
S = [-1] + S + [-1]
count = 0
ANS = 0
for i in range(1, N + 3):
    if S[i] == S[i - 1]:
        count += 1
    else:
        ANS += tr(count)
        count = 1
print(ANS)

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
SUM = [0]
for a in A:
    SUM.append((SUM[-1] + a) % M)
from collections import Counter

counter = Counter(SUM)
ANS = 0
for i in list(counter.values()):
    ANS += i * (i - 1) // 2
print(ANS)

-S = [0] * (N + 1) -for i in range(N): -    S[i + 1] = (A[i] + S[i]) % M +SUM = [0] +for a in A: +    SUM.append((SUM[-1] + a) % M) +from collections import Counter - -def tr(k): -    return k * (k - 1) // 2 - - -S.sort() -S = [-1] + S + [-1] -count = 0 +counter = Counter(SUM) -for i in range(1, N + 3): -    if S[i] == S[i - 1]: -        count += 1 -    else: -        ANS += tr(count) -        count = 1 +for i in list(counter.values()): +    ANS += i * (i - 1) // 2