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

int n, k;
vector<int> x;

int main()
{
	cin >> n >> k;
	x.resize(n);
	for( int i = 0; i < n; i++ ) {
		cin >> x[i];
	}

	int ans = INT32_MAX;
	for( int l = 0; l < n - k + 1; l++ ) {
		int r = l + k -1;
		ans = min( ans, abs(x[l]) + abs(x[r] - x[l]) );
		ans = min( ans, abs(x[r]) + abs(x[r] - x[l]) );
	}

	cout << ans << endl;

	return 0;
}
