N, M = map(int,input().split())
A = [int(i) for i in input().split()]
sumA = [0 for i in range(N + 1)]
for i in range(N):
    sumA[i + 1] = (A[i] + sumA[i]) % M
ans = 0

for j in range(N):
    ans += sumA[j:].count(sumA[j]) - 1

print(ans)