#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int x,n,k;cin>>n>>k;
	int a[100010],d[100010];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int m=1e9;
	for(int i=0;i<n;i++)
	{
		if(i<k-1)d[i]=1e9;
		else d[i]=min(a[i]-a[i-k+1]+abs(a[i-k+1]),a[i]-a[i-k+1]+abs(a[i]));
		m=min(d[i],m);
	}
	cout<<m<<endl;
}