#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int a[N];
int main()
{   
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    int ans = 0x3f3f3f3f;
    for (int i = 0; i <= n - k; i++)
        ans = min(ans, min(abs(a[i]) + a[i + k - 1] - a[i], abs(a[i + k - 1]) + a[i + k - 1] - a[i]));
    printf("%d", ans);
    return 0;
}