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