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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define ROF2(i,x,y) for(int i = (y) ; i >= (x) ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
inline ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }

template<class T,class U>
ostream &operator<<(ostream &os,const pair<T,U> &x) {
    return os<<"("<<x.first<<","<<x.second<<")";
}

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        os << x[0];
        for (int i=1;i<x.size();i++) os << endl << " " << x[i];
    } else os << "[]";
    os << "]";
    return os;
}




int main() {
  //  freopen("in.txt","r",stdin);
    int n,k;cin>>n>>k;
    vi a(n);
    FOR(i,n) cin>>a[i];
    auto zero=lower_bound(a.begin(),a.end(),0);
    if (zero==a.begin()){
        if (*zero==0) {
            if (k==1) cout << 0;
            else cout << a[k-2];
        }
        else cout << a[k-1];
    }else if (zero==a.end()){
        cout << -a[n-k];
    }else {
        vi derecha(k + 1, INF);
        vi izq(k + 1, INF);
        derecha[0] = izq[0] = 0;
        if (*zero != 0) {
            auto it = zero;
            while (it != a.end() && it - zero < k) {
                derecha[it - zero + 1] = *it;
                ++it;
            }
            it = zero;
            --it;
            while (it != a.begin() && zero - it <= k) {
                izq[zero - it] = -(*it);
                --it;
            }
            izq[zero - it] = -(*it);
        } else {
            izq[1] = derecha[1] = 0;
            auto it = ++zero;
            while (it != a.end() && it - zero < k - 1) {
                derecha[it - zero + 1] = *it;
                ++it;
            }
            it = zero;
            --it;
            while (it != a.begin() && zero - it < k ) {
                izq[zero - it + 1] = -(*it);
                --it;
            }
            izq[zero - it+1] = -(*it);
        }
        int t = INF;
        for (int i = k; i >= 0; --i) {
            t = min(t, derecha[i] + 2 * izq[k - i]);
            t = min(t, izq[i] + 2 * derecha[k - i]);
        }
        cout << t;
    }




    return 0;
}


Measured memory_bytes: 1408