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

SUM=[0]
for a in A:
    SUM.append((SUM[-1]+a)%M)

from collections import Counter
counter=Counter(SUM)

ANS=0
for i in counter.values():
    ANS+=i*(i-1)//2

print(ANS)