#include<bits/stdc++.h>
using namespace std;
int x[100010],n,k,pos=-1,an=0x3f3f3f3f;
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	for (int i=1;i<=n-1;i++)
		if (x[i]<=0 && x[i+1]>0) pos=i; 
	if (pos==-1)
	{
		if (x[1]>0) printf("%d",x[k]);
		else printf("%d",abs(x[n-k+1]));
		return 0;
	}
	for (int i=1;i<=pos;i++) an=min(an,abs(x[i])+x[i+k-1]-x[i]);
	printf("%d",an);
}