#include <iostream>
#include <vector>
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<n-k+1; i++){
        int left = x[i];
        int right = x[i+k-1];

        ans = min(ans,min(abs(left),abs(right))+right-left);
    }
    cout<<ans<<endl;
    return 0;
}