#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define inf 0x3f3f3f3f #define CLEAR(a) a = decltype(a)() #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define pii pair #define pcc pair #define pic pair #define pci pair #define VS vector #define VI vector #define DEBUG(x) cout<<#x<<": "<> N >> M; vector D(M); for (auto &a : D) cin >> a; sort(ALL(D)); int mi = inf; for (int i = 0; i + N - 1 < D.size(); ++i) { int left = i; int right = i + N - 1; if (D[right] < 0) mi = min(-D[left], mi); else if (D[left] > 0) { mi = min(D[right], mi); break; } else { mi = min({ mi, -D[left] * 2 + D[right], -D[left] + 2 * D[right] }); } } cout << mi << endl; return 0; }