# encoding: utf-8
N, M = list(map(int, input().split()))
P=map(int, input().split())
Acnt = [0 for i in range(M)]
sym = 0

for A in P:
    sym = (sym + A) % M
    Acnt[sym] += 1
L=[cnt * (cnt - 1) for cnt in Acnt]
print(int(Acnt[0] + sum(L) / 2))

