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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int ans = 2000000000;
  for (int i = 0; i <= n - k; i++) {
    int l = x[i];
    int r = x[i + k - 1];
    ans = min({ans, abs(l) + abs(r - l), abs(r) + abs(r - l)});
  }
  cout << ans << endl;
}