#include "bits/stdc++.h"
using namespace std;
int main(){
    int n, k; cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;++i)cin>>a[i];

    int ans=INT_MAX,t;
    for(int i=0;i<n-k+1;++i){
        t=min(a[i+k-1]-a[i]+abs(a[i+k-1]), a[i+k-1]-a[i]+abs(a[i]));
        if(ans>t)ans=t;
    }
    cout<<ans;
}