n,m=map(int,input().split())
a,d=list(map(int,input().split()))+[0],{}
for i in range(n):
	a[i]%=m
	a[i+1]+=a[i]
a[n]=0
for i in range(n+1):
	if a[i] in d:
		d[a[i]] += 1
	else:
		d[a[i]] = 1
print(sum([x*(x-1)//2 for x in d.values()]))