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

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

S=[0 for i in range(N+1)]

for i in range(N):

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

D=dict()

ans=0

for i in range(N+1):

  if S[i] in D:

    D[S[i]]+=1

  else:

    D[S[i]]=1

  ans+=D[S[i]]-1

print(ans)

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

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

D={0:1}

S=[0 for i in range(N)]

S[0]=A[0]%M

if S[0] in D:

    D[S[0]]+=1

else:

    D[S[0]]=1

for i in range(1,N):

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

    if S[i] in D:

        D[S[i]]+=1

    else:

        D[S[i]]=1

ans=0

for i in D:

    ans+=(D[i]*(D[i]-1))//2

print(ans)

N, M = list(map(int, input().split()))
A = [int(i) for i in input().split()]
S = [0 for i in range(N + 1)]
for i in range(N):
    S[i + 1] = (S[i] + A[i]) % M
D = dict()
ans = 0
for i in range(N + 1):
    if S[i] in D:
        D[S[i]] += 1
    else:
        D[S[i]] = 1
    ans += D[S[i]] - 1
print(ans)

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
D = {0: 1}
S = [0 for i in range(N)]
S[0] = A[0] % M
if S[0] in D:
    D[S[0]] += 1
else:
    D[S[0]] = 1
for i in range(1, N):
    S[i] = (S[i - 1] + A[i]) % M
    if S[i] in D:
        D[S[i]] += 1
    else:
        D[S[i]] = 1
ans = 0
for i in D:
    ans += (D[i] * (D[i] - 1)) // 2
print(ans)

-A = [int(i) for i in input().split()] -S = [0 for i in range(N + 1)] -for i in range(N): -    S[i + 1] = (S[i] + A[i]) % M -D = dict() -ans = 0 -for i in range(N + 1): +A = list(map(int, input().split())) +D = {0: 1} +S = [0 for i in range(N)] +S[0] = A[0] % M +if S[0] in D: +    D[S[0]] += 1 +else: +    D[S[0]] = 1 +for i in range(1, N): +    S[i] = (S[i - 1] + A[i]) % M -    ans += D[S[i]] - 1 +ans = 0 +for i in D: +    ans += (D[i] * (D[i] - 1)) // 2