#include "bits/stdc++.h" using namespace std; typedef long long ll; ll N; int main(){ //条件を逆に読み替えた //Nが1になるまで +1 するか 2で割る ll N, M; cin >> N >> M; ll ans = 1145141919; vector d(N, 0); for(ll i = 0; i < M; i++){ cin >> d[i]; } ll i = 0; while(i < M && i + N - 1 < M){ ll t_ans = 0; if(d[i] < 0 && d[i+N-1] < 0){ t_ans = abs(d[i]); }else if(d[i] <= 0 && d[i+N-1] >= 0){ t_ans = d[i+N-1] - d[i] + min(abs(d[i]), d[i+N-1]); }else{ t_ans = d[i+N-1]; } ans = min(ans, t_ans); i++; } cout << ans << endl; }