#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <list>
#include <fstream>
#include <ctime>
#include <random>
#include <array>

using namespace std;

using ll = long long;


void dump(const vector<int>& a) {
    for (int i = 0; i < a.size(); i++) {
        cerr << a[i] << ' ';
    }
    cerr << endl;
}

vector<pair<int,int>> factorise(long long m) {
    vector<pair<int,int>> res;
    for (long long i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            int cnt  =0 ;
            while (m % i == 0) {
                cnt++;
                m /= i;
            }
            res.emplace_back(i, cnt);
        }
    }
    return res;
};
using ll = long long;

ll gcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd (b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

bool debug = false;
//const int mod = int(1e9) + 7;
//const int SZ = 10100;
//const int MX = 210500;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
#define ll long long
#define sqr(x) (x)*(x)
#define FREIN(file) freopen(file, "rt", stdin)

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)

const int magic = 3;
const int INF  = 1e9;
#ifndef M_PI
#define M_PI 3.14159265358979323
#endif
void solve();
void init();


//
int main(int argc, char** argv)
{
    cout.precision(15);


#ifdef LOCAL
    freopen("../in.txt", "r", stdin);
//    freopen("../out.txt", "w", stdout);
#endif
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
    int t = 1;
//        cin >> t;
//        init();
    for (int tt = 1; tt <= t; tt++) {
//        cout << "Case #" << tt << ": ";
        solve();
    }
    return 0;
}
// Solution ***********************************************************************************************

const int MX = 100500;
int x[MX];

void solve() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int ans = 1e9;
    for (int i = 0; i < n - k + 1; i++) {
        if (x[i] < 0 && x[i + k - 1] < 0) {
            ans = min(ans, -min(x[i], x[i + k - 1]));
        } else if (x[i] > 0 && x[i + k - 1] > 0) {
            ans = min(ans, max(x[i], x[i + k - 1]));
        } else {
            int a = -x[i];
            int b = x[i + k - 1];
            if (a > b) {
                swap(a, b);
            }
            ans = min(ans, 2 * a + b);
        }
    }
    cout << ans << "\n";

}


Measured memory_bytes: 640