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