from collections import Counter
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=[0]*n
s[0]=a[0]%m
for i in range(1,n):
    s[i]=(s[i-1]+a[i])%m
S=Counter(s)
ans=0
for i in S.values():
    ans+=i*(i-1)//2
print(ans if 0 not in S.keys() else ans+S[0])
