#include<bits/stdc++.h>

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<ll>x(n+10);
  ll rui[n+10]={};
  for(int i=0;i<n;i++){
    cin>>x[i];
    rui[i+1]=rui[i]+x[i];
  }
  if(k==1&&n==1){
    cout<<x[0]<<endl;
    return 0;
  }
  ll ans=llINF;
  for(int i=0;i<n-k;i++){
    if((x[i]<0&&x[i+k]>0)){
      //cout<<x[i+k-1]-x[i]<<endl;
      ans=min(ans,(x[i+k-1]-x[i])+min(abs(x[i]),x[i+k-1]));
    }else if(x[i+k-1]<=0){
      ans=min(x[i],ans);
    }else if(x[i]>=0){
      ans=min(x[i+k-1],ans);
    }
  }
  cout<<ans<<endl;
  return 0;
}
