#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i = 0;i < n;++i)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){

    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = INF;
    rep(i,n-k+1) {
        ans = min(ans,abs(x[i])+abs(x[i+k-1]-x[i]));
        ans = min(ans,abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
    }
    cout << ans << endl;

    return 0;
}
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, L;
    cin >> N >> L;

    int orderL = L;
    int orderR = L + N - 1;
    int eat;

    if(0 < orderL) {
        eat = orderL;
    } else if(orderR < 0) {
        eat = orderR;
    } else {
        eat = 0;
    }

    int ans = (orderL + orderR) * (orderR - orderL + 1) / 2 - eat;

    cout << ans << endl;

    return 0;
}
