let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, K) = (input[0], input[1]-1)
let x = readLine()!.characters.split(" ").map{Int(String($0))!}
var ans = 200000000
for i in 0..<N-K {
    let time = min(abs(x[i]), abs(x[i+K])) + abs(x[i]-x[i+K])
    ans = min(time, ans)
}
print(ans)