from collections import Counter

n,m=map(int,input().split())
a=[int(i)%m for i in input().split()]

s=[0]
for i in range(1,n+1):
	s.append((s[i-1]+a[i-1])%m)
c=Counter(s)
ans=0
for i in c.keys():
	ans+=c[i]*(c[i]-1)//2
print(ans)
