#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    ll y[x];
    for (int i=0;i<x;i++){
            cin>>y[i];
    }
    ll ans=1e18;
    for (int i=0;i<x-k+1;i++){
        ll l=y[i],r=y[i+k-1];
        if (l<0&&r<0)
            ans=min(ans,-l);
        else if (r>0&&l>0)
            ans=min(ans,r);
        else if (abs(l)>abs(r))
            ans=min(ans,2*abs(r)+abs(l));
        else
            ans=min(ans,abs(r)+2*abs(l));
    }
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    ll L, R;
    cin >> L >> R;
    if (R - L >= 2050) cout << 0 << endl;
    else {
        ll ans = 2018;
        for (ll i = L; i < R; i++)
            for (ll j = i + 1; j <= R; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        cout << ans << endl;
    }
}