n,m=map(int,raw_input().split())
lis=map(int,raw_input().split())
dic={}
c=0
dic[0]=1
#print lis
for i in xrange(n):
    c = (c+lis[i])%m
    #print c
    if c in dic:
        dic[c]+=1
    else:
        dic[c]=1
#print dic
ans=0
for i in dic:
    ans += (dic[i]*(dic[i]-1))/2
print ans