#include using namespace std; #define sorted(a) sort(a.begin(), a.end()); typedef long long ll; const long mod = 1e9 + 7; int main(void) { #ifdef DEBUG freopen("input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M; cin >> N >> M; int D[1000]; for (int i = 0; i < M; i++) cin >> D[i]; int dist; int ans = 10000; for (int i = 0; i + N <= M; i++) { dist = D[i+N-1] - D[i] + min(abs(D[i]), abs(D[i+N-1])); ans = min(ans, dist); } cout << ans << endl; return 0; }