n,m=map(int,input().split())
a=list(map(int,input().split()))
a[0]%=m
for i in range(1,n):
	a[i]+=a[i-1]
	a[i]%=m
a.sort()
l=0
p=1
s=0
for i in range(0,n):
	if a[i]-l:
		l=a[i]
		p=i-p
		s+=p*(p-1)
		p=i
p=n-p
s+=p*(p-1)
print(int(s/2))