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

typedef long long ll;

int n,k;
ll A[1000006];

int main(){
	cin >> n >> k;

	for(int i=0;i<n;i++)
		cin >> A[i];

	ll ans=INT_MAX;

	for(int i=0;i+k<=n;i++){
		ll l=A[i];
		ll r=A[i+k-1];

		if(l>=0)
			ans=min(ans,r);
		else if(r<=0)
			ans=min(ans,-l);
		else
			ans=min(ans,min(abs(l),abs(r))+r-l);
	}

	cout << ans << endl;

	return 0;
}