n,m = map(int,input().split())

a = list(map(int,input().split()))

b = [0 for i in range(n+1)]

for i in range(n):
	b[i+1] = (b[i]+a[i])%m

c = {}
for i in b:
	if i in c:
		c[i] += 1
	else:
		c[i] = 1

ans = 0

for i in c:
	ans += (c[i]*(c[i]-1)//2)
print(ans)