#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k, res=INT_MAX;
    cin>>n>>k;
    int a[n];
    for(auto &x: a) cin>>x;
    for(int i=0; i<=n-k; ++i){
        int tmp=abs(a[i+k-1]-a[i]);
        res=min(res, tmp+min(abs(a[i]), abs(a[i+k-1])));
    }
    cout<<res;
    return 0;
}