let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, K) = (input[0], input[1])
let x = readLine()!.characters.split(" ").map{Int(String($0))!}
let plus = x.filter{$0>=0}
let minus = x.reverse().filter{$0<0}
var ans = 200000000
for i in max(0, K-minus.count-1)..<min(K, plus.count) {
    var dist = 0
    dist += plus[i]
    if i+1 < K {
        dist -= minus[K-i-2]*2
    }
    ans = min(dist, ans)
}
for i in max(0, K-plus.count-1)..<min(K, minus.count) {
    var dist = 0
    dist -= minus[i]
    if i+1 < K {
        dist += plus[K-i-2]*2
    }
    ans = min(dist, ans)
}
print(ans)