n,m=map(int, input().split())
h=list(map(int, input().split()))
a=[0]*(n+1)
num={0:1}
for i in range(n):
    a[i+1]=(a[i]+h[i])%m
    if a[i+1] in num:
        num[a[i+1]]+=1
    else:
        num[a[i+1]]=1

ans=0
for i in num.values():
    if i>2:
        ans+=(i*(i-1))//2
print(ans)