#abc105d
import sys
from collections import defaultdict

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
d=defaultdict(int)
res=0
s=0
d[0]=1
for i,x in enumerate(a):
 x%=m
 s+=x
 res+=d[s%m]
 d[s%m]+=1
print res
