N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
Accum = [0]*(N+1)


def comb(n):
    if n >= 2:
        return n*(n-1)//2
    else:
        return 0


for i in range(N-1):
    Accum[i+1] = (Accum[i]+A[i+1]) % M

ans = 0
for i in range(M):
  	if i == 0:
      ans += Accum.count(i)
    else:
    	c = Accum.count(i)
    	ans += comb(c)
print(ans)
