program test
integer::d
 allocatable :: a(:), b(:)
read(*,*) N, c
z=N-c+1
allocate(a(N),b(z))
read(*, *)(a(i), i = 1,N)
do i=1,N-c+1
k=i+c-1
x=a(i)
y=a(k)
m=min(x,y)
b(i)=abs(m)+(y-x)
end do
d=minval(b)
print*,d
end program test