#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
#include<random>
 
using namespace std;

int main() { 
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	for (auto& e : x) {
		cin >> e;
	}
	int ans = { 1000000 };
	for (int j = 0; j + k - 1 < n; j++) {
		int a = x[j];
		int b = x[j+k-1];
		if (a >= 0) {
			ans = min(ans, b);
			break;
		}
		if (b <= 0) {
			ans = min(ans, -a);
		}
		else {
			ans = min(ans, b - a + min(-a, b));
		}

	}


	cout << ans << endl;
	return 0;
}