from collections import Counter
N,M = map(int,input().split())
A = list(map(int,input().split()))

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

cnt = Counter(sumA).values()
ans = sum(i*(i-1)//2 for i in cnt)

print(ans)