n,m=map(int, input().split())
a=list(map(int,input().split())) 
b=[sum(a[0:i]) for i in range(1,n+1)]
c=[b[i]%m for i in range(n)]
ans=0
import collections
k=list(collections.Counter(c).items())
for x in k:
    j=True
    if x[0]==0:
        ans+=x[1]*(x[1]+1)//2
        j=False
    if x[1]>1 and j:
        ans+=(x[1]-1)*x[1]//2
print(ans)