#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){
  long long n,k,i,j,ans = 1000000000000;cin >> n >> k;
  long long x[n];
  for(i=0;i<n;i++) cin >> x[i];
  for(i=0;i<=n-k;i++){
    j=i+k-1;
    if(x[i]<=0 && 0<=x[j]) ans = min(ans,min(-x[i],x[j])*2+max(-x[i],x[j]));
    else ans = min(ans,max(abs(x[i]),abs(x[j])));
  }
  cout << ans << endl;
}