program test
integer::a,b,c,d,i,N,x,y,z,t,u,k,m
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)
t=abs(x)
u=abs(y)
m=min(t,u)
b(i)=m+(y-x)
end do
d=minval(b)
print*,d
end program test