implicit none
integer :: n,k
integer,allocatable :: x(:)
integer :: i,j,d,t,tmin

read *,n,k
allocate(x(n))
read *,(x(i),i=1,n)

tmin = 1000000000
j = k
do i = 1,n-k+1
   d = abs(x(j) - x(i))
   t = min(abs(x(i)) + d, abs(x(j)) + d)
   if (t < tmin) then
      tmin = t
   endif
   j = j + 1
enddo

print '(i0)',tmin
end