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

end program test
