program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,a,b,l
    
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,k
    allocate(x(n))
    allocate(y(n))
    read(*,*)x
    if (sum(x)==0)then
        write(*,*)x
        stop
    end if
    if (k>=n)then
        do i=1,n
            y(i)=n
        end do
        write(*,*)y
        stop
    end if
    

    do i=1,k
        do j=i,n
            y(j)=0
        end do
        do j=1,n
            a=x(j)
            if (a>0)then
                y(j)=1
                if (j+a+1<=n)then
                do l=1,a+1
                    y(j+l)=y(j+l)+1
                end do
                else
                    do l=1,n
                        y(j+l)=y(j+l)+1
                    end do
                end if

                if (j-a-1>0)then
                    do l=1,a+1
                        y(j-l)=y(j-l)+1
                    end do
                else if (j>1)then
                    do l=1,j-1
                            y(j-l)=y(j-l)+1
                     end do
                end if
                   
            end if

        end do
        do j=1,n
        x(j)=y(j)
        end do
        
    end do

    write(*,*) y
  
    stop
end program sample
  

