program RSN
    implicit none
    integer(8) :: n, k, i, j, cnt = 0, ans = 0
    integer(8),allocatable :: a(:)
    read *, n, k
    allocate(a(n))
    read *, a(n)
    do i = 1, n
        do j = 1, n
            !if(j >= i)then
                ans = sum(a(i:j))
                if(mod(ans, k) .eq. 1 + j - i)then
                    cnt = cnt + 1
                end if
            !else if(i >= j)then
            !    ans = sum(a(j:i))
            !    if(mod(ans, k) .eq. 1 + i - j)then
            !        cnt = cnt + 1
            !    end if
            !end if
        end do
    end do
    print *, cnt
end program