n,m=map(int,input().split())
a=list(map(int,input().split()))
a[0]=a[0]%m
for i in range(n-1):
    a[i+1]=(a[i]+a[i+1])%m
result=0
for i in range(n):
    if a[i]==0:
        result+=1
    for j in range(i+1,n):
        if a[i]==a[j]:
            result+=1
print(result)