#include <bits/stdc++.h>
using namespace std;
#define ll long long
#ifdef LOCAL
#include "debug.h"
#else
#define out(...) 0
#endif
void solve() {
int n, k; cin >> n >> k;
vector<int> v(n);
for(int& i : v) {
cin >> i;
}
int ans = 1E9;
for (int i = k - 1; i < n; ++i) {
if (v[i - k + 1] >= 0) ans = min(ans, v[i]);
else if (v[i] <= 0) ans = min(ans, abs(v[i - k + 1]));
else {
ans = min(ans, abs(v[i - k + 1]) * 2 + v[i]);
ans = min(ans, abs(v[i - k + 1]) + v[i] * 2);
}
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int tc = 1;
// cin >> tc;
for(int cs = 1; cs <= tc; cs++) {
// cout << "Case " << cs << ": ";
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZyAKCiNpZmRlZiBMT0NBTAogICNpbmNsdWRlICJkZWJ1Zy5oIgojZWxzZQogICNkZWZpbmUgb3V0KC4uLikgMAojZW5kaWYKCgp2b2lkIHNvbHZlKCkgewogIGludCBuLCBrOyBjaW4gPj4gbiA+PiBrOwogIHZlY3RvcjxpbnQ+IHYobik7CgogIGZvcihpbnQmIGkgOiB2KSB7CiAgICBjaW4gPj4gaTsKICB9CgogIGludCBhbnMgPSAxRTk7CgogIGZvciAoaW50IGkgPSBrIC0gMTsgaSA8IG47ICsraSkgewogICAgaWYgKHZbaSAtIGsgKyAxXSA+PSAwKSAgYW5zID0gbWluKGFucywgdltpXSk7ICAgICAgICAgICAgICAKICAgIGVsc2UgaWYgKHZbaV0gPD0gMCkgICAgIGFucyA9IG1pbihhbnMsIGFicyh2W2kgLSBrICsgMV0pKTsKICAgIGVsc2UgewogICAgICBhbnMgPSBtaW4oYW5zLCBhYnModltpIC0gayArIDFdKSAqIDIgKyB2W2ldKTsKICAgICAgYW5zID0gbWluKGFucywgYWJzKHZbaSAtIGsgKyAxXSkgKyB2W2ldICogMik7CiAgICB9CiAgfQogIGNvdXQgPDwgYW5zIDw8ICdcbic7Cn0KCmludCBtYWluKCkgewogIGlvczo6c3luY193aXRoX3N0ZGlvKDApOyAKICBjaW4udGllKDApOyAKCiAgaW50IHRjID0gMTsKICAvLyBjaW4gPj4gdGM7CgogIGZvcihpbnQgY3MgPSAxOyBjcyA8PSB0YzsgY3MrKykgewogICAgLy8gY291dCA8PCAiQ2FzZSAiIDw8IGNzIDw8ICI6ICI7CiAgICBzb2x2ZSgpOwogIH0KICByZXR1cm4gMDsKfQo=