program main
  integer::n,i,j,k,ans,le,s,l
  integer,allocatable::a(:)
  !character(10000)::s
read(*,*)n,k
allocate(a(n))
read(*,*) a
ans=0
do i=1,n
  do j=i,n
    s=sum(a(i:j))
    l=j-i+1
    if(mod(s,k)==l) ans=ans+1
  end do
end do
write(*,*) ans
stop
end program
