#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    for(int i=0;i<n;i++)cin>>x[i];
    int ans=1e9;
    for(int i=0;i+k-1<n;i++){
        int left=x[i],right=x[i+k-1];
        ans = min(ans,min((right-left)+abs(right),(right-left)+abs(left)));
    }
    cout<<ans<<endl;
    return 0;
}
