#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N = 100010;
int n, k, a[N];
 
 
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = 2e9+10;
    for (int i = 1; i+k-1 <= n; i++){
        if ((long long)a[i]*a[i+k-1] < 0)
            ans = min(ans, (int)abs(a[i])+(int)abs(a[i+k-1])+min((int)abs(a[i]), (int)abs(a[i+k-1])));
        else ans = min(ans, max((int)abs(a[i]), (int)abs(a[i+k-1])));
    }
    cout << ans;
    return 0;
}