import collections

N,M = map(int,input().split())
A=[int(x) for x in input().split()]
B=[]
for i in range(N+1):
  B+=[sum(A[:i])]
C=[]
for i in range(N+1):
  C +=[B[i]%M]
answer=0
D = collections.Counter(C)
E = list(D.values())

for i in range(len(E)):
  answer += E[i]*(E[i]-1)//2
print(answer)