n,m=[int(x) for x in input().split()]
a=[int(x)%m for x in input().split()]
 
a_ruijou_wa=[0]*(n+1)
for i in range(1,n+1):
    a_ruijou_wa[i]=a_ruijou_wa[i-1]+a[i-1]
    
ans=0
for ato in range(n):
    for sentou in range(ato+1,n+1):
        if a_ruijou_wa[n] - a_ruijou_wa[ato]<m:
            break
        if (a_ruijou_wa[sentou] - a_ruijou_wa[ato])%m==0:
            ans+=1
print(ans)