#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { int N,M; cin >> N >> M; vector V(M); for ( int i = 0; i < M; i++ ) { cin >> V[i]; } sort( V.begin(), V.end() ); long long ans = LLONG_MAX; for ( int i = 0; i <= M-N; i++ ) { long long a; long long x = V[i]; long long y = V[i+N-1]; if ( x*y >= 0 ) { a = max( abs(x), abs(y) ); } else { a = min(abs(x),abs(y))*2 + max(abs(x),abs(y)); } ans = min( ans, a ); } cout << ans << endl; return 0; }