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





countlist=dict()

check=set()





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

    countlist[S[i]]=countlist.get(S[i],0)+1



    

    





ANS=countlist.get(0,0)



for i in list(countlist.keys()):

    ANS+=tr(countlist[i])







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()))
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


countlist = dict()
check = set()
for i in range(1, N + 1):
    countlist[S[i]] = countlist.get(S[i], 0) + 1
ANS = countlist.get(0, 0)
for i in list(countlist.keys()):
    ANS += tr(countlist[i])
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)

-countlist = dict() -check = set() -for i in range(1, N + 1): -    countlist[S[i]] = countlist.get(S[i], 0) + 1 -ANS = countlist.get(0, 0) -for i in list(countlist.keys()): -    ANS += tr(countlist[i]) +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