# coding: utf-8
from collections import defaultdict

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

B=[]

s=0
for a in A:
    s+=a
    B.append(s)
F=defaultdict(int)
for b in B:
    F[b%M]+=1
ans=0
for b in B:
    if b%M==0:ans+=1
    ans+=int((F[b%M]-1)/2)
print(ans)