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

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

ans = 0

C = Counter(A)
for num, val in C:
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)
