from collections import defaultdict
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
d=defaultdict(int)
sm=0 
d[0]=1 
ans=0 
for i in l: 
    sm+=i 
    sm%=m 
    ans+=d[sm]
    d[sm]+=1 
print(ans)