"use strict";
    
const absOfArray = array => {
    const N = array.length;
    const temp = [];
    
    if(array.length === 1) {
        return array[0];
    }
    
    for(let i=1; i<N; i++) {
        temp.push(Math.abs(array[i-1] - array[i]));
    }
    
    return temp.reduce((m,n)=>m+n);
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    let K = parseInt(arg[0].split(" ")[1]);
    const X = arg[1].split(" ").map(n=>parseInt(n));
    
    const minus = X.filter(n=>n<0).slice(-K);
    const plus  = X.filter(n=>n>0).slice(0, K);
    
    const newX = minus.concat([0]).concat(plus);
    
    let memo = absOfArray(newX.slice(0, K + 1));
    let answer = memo;
    
    // console.log(minus);
    // console.log(plus);
    // console.log(newX);
    
    if(K > newX.length) {
        console.log(memo);
        return;
    }
    
    for(let i=1; i<=newX.length-K-1; i++) {
        memo -= Math.abs(newX[i-1] - newX[i]);
        memo += Math.abs(newX[i + K]);
        
        answer = Math.min(memo, answer);
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));