import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		int total = 0;
		int ans = 0;
		Scanner in=new Scanner(System.in);
		in.useDelimiter("\n");
		String infoA = in.next();
		String infoB = in.next();
		String[]infoA_ = infoA.split(" ");
		String[]infoB_ = infoB.split(" ");
		
		int[]laZhus = new int[Integer.valueOf(infoA_[0].trim())];//蜡烛位置
		int num = Integer.valueOf(infoA_[1].trim());//点亮个数
		for (int i = 0; i < laZhus.length; i++) {
			laZhus[i]=Integer.valueOf(infoB_[i].trim());
		}
		int[]subLaZhus = new int[num];
		for (int i = 0; i < laZhus.length+1-num; i++) {
			for (int j = 0; j < num; j++) {
				subLaZhus[j]=laZhus[i+j];
			}
			if(subLaZhus[0]*subLaZhus[num-1]<0){
				//有正数也有复数
				if(subLaZhus[0]*-1>subLaZhus[num-1]){
					total = subLaZhus[num-1]*2+subLaZhus[0]*-1;
				}else{
					total = subLaZhus[0]*-2+subLaZhus[num-1];
				}
			}else{
				//向一边走
				if(subLaZhus[0]<0){
					total = subLaZhus[0]*-1;
				}else{
					total = subLaZhus[num-1];
				}
			}
			if(ans==0){
				ans=total;
			}else{
				ans=ans<total?ans:total;
			}
		}
		System.out.println(ans);
	}
}
