program atcoder
	implicit none
	integer :: i,n,ans=0,k,j
	integer,allocatable,dimension(:) :: a
	read*,n,k
	allocate(a(n))
	read(*,*)(a(i),i=1,n)
	do i = 1,n
		do j=0,n-i
			if( mod(sum(a(i:i+j)),k) == j+1 )then
				ans = ans+1
			endif
		end do
	end do
	write(*,*)ans
	stop 
end program atcoder
