"use strict"

function main(input) {
  input = input.split("\n").map(v => v.split(/\s/).map(v => ~~v))
  const k = input[0][1]
  const minus = [0]
  const plus = [0]
  for (let i in input[1]) {
    if (input[1][i] >= 0) {
      plus.push(input[1][i])
    } else {
      minus.push(Math.abs(input[1][i]))
    }
  }
  minus.sort((a, b) => a - b)

  let ans
  if (plus.length >= k && minus.length <= 1) {
    ans = plus[k]
  } else if (minus.length >= k && plus.length <= 1) {
    ans = minus[k]
  } else if (minus.length > 1 && plus.length > 1) {
    //左右の組み合わせチェックで一番コスト低いもの

    for (let i = 1; i <= k; i++) {
      if (minus.length > i && plus.length > k - i) {
        let a = minus[i] ? minus[i] : 0

        let b = plus[k - i] ? plus[k - i] : 0

        //もどり道のコスト
        let c = minus[i] > plus[k - i] ? plus[k - i] : minus[i]

        let tmp = a + b + c

        ans = ans ? Math.min(ans, tmp) : tmp

        // console.log(ans, i, k - i, a, b, c)
      }

      // console.log(ans)
    }
  }
  console.log(ans)

  // console.log(minus, plus)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))
