local mmi, mma = math.min, math.max
local n, k = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local ret = 1000000007
for left = 1, n - k + 1 do
  local right = left + k - 1
  if 0 <= t[left] then
    ret = mmi(ret, t[right])
  elseif t[right] <= 0 then
    ret = mmi(ret, -t[left])
  else
    if -t[left] < t[right] then
      ret = mmi(ret, t[right] - 2 * t[left])
    else
      ret = mmi(ret, 2 * t[right] - t[left])
    end
  end
end
print(ret)
