#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i,n){
        if (ans * 2 > ans + k)  ans += k;
        else ans *= 2;
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = (s); i < n; ++i)
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i,0,n) cin >> x[i];
  int ans = 1000000000;
  rep(i,0,n-k+1) {
    int a = x[i], b = x[i+k-1];
    if (b < 0) {
      ans = min(ans, abs(a));
    } else if (a >= 0) {
      ans = min(ans, b);
    } else {
      ans = min(ans, b-a + min(abs(a), abs(b)));
    }
  }
  cout << ans << endl;
  return 0;
}