from collections import Counter
N, M = map(int, input().split())
A = list(map(int, input().split()))
cumsum = [0]
for a in A:
    cumsum.append((cumsum[-1] + a) % M)

ans = 0
for v in Counter(cumsum).values():
    ans += v * (v - 1) // 2

print(ans)