#include using namespace std; main(){ int N,M,D[1000]; scanf("%d%d",&N,&M); for(int i = 0;i < M;i++){ scanf("%d",&D[i]); } int mini = 100000000; int head = M-1,tail; for(int i = 0;i < M;i++){ if(D[i]>=0){ head = i; break; } } if(head+N>M){ tail = M-1; head = M-N; }else{ tail = head+N-1; } while(head>=0){ int h = abs(D[head]),t = abs(D[tail]); if(D[head]*D[tail] >= 0){ mini = min(mini,max(h,t)); }else{ mini = min(mini,min(h,t)*2+ max(h,t)); } if(D[tail]<0)break; head--;tail--; } printf("%d\n",mini); }