#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define ctos(d) string(1,d) #define MOD 1000000007 int main(){ int n,m; cin>>n>>m; vector v; rep(i,0,m){ int a; cin>>a; v.pb(a); } int ans = 1000000000; rep(i,0,n+1){ int c1 = 0; int c2 = 0; int index = 0; int mx = 0; int mn = 0; while(1){ if(c1==i)break; if(index==m)break; if(v[index]>=0){ c1++; mx = max(mx,v[index]); } index++; } index = n; while(1){ if(c2==n-i)break; if(index==-1)break; if(v[index]<0){ c2++; mn = min(mn,v[index]); } index--; } if(c1==i&&c2==n-i){ ans = min(ans,mx*2-mn); ans = min(ans,mx-mn*2); } } cout << ans << endl; return 0; }