N, M = map(int, input().split())

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

d = {0: 1}

A_sum = 0

for i in range(0,N):
    A_sum += A[i]
    d[A_sum%M] = d.get(A_sum%M, 0) + 1

ans = 0

for val in d.values():
    ans += val*(val-1)/2

print(int(ans))
    