#include <bits/stdc++.h>
using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  vector<int64_t> A(N);
  for(int i=0;i<N;++i) cin>>A[i];

  int64_t ans=1e10;
  
  for(int i=0;i+(K-1)<N;++i){
    if(A[i]>=0) ans = min(ans,A[i+K-1]);
    else if(A[i+K-1]<=0) ans = min(ans,-A[i]);
    else ans = min(ans,min(-2*A[i]+A[i+K-1],2*A[i+K-1]-A[i]));
  }

  cout<<ans<<endl;
}
