#include #include #include using namespace std; int main(int argc, const char* argv[]) { int N, M; cin >> N >> M; int D[M]; for (auto&& d : D) cin >> d; sort(D, &D[M]); int minval = 10000 * 3; for (int i = 0; i <= M - N; i++) { int lv = abs(min(D[i], 0)); int rv = abs(max(D[i + N - 1], 0)); minval = min(minval, min(lv * 2 + rv, lv + rv * 2)); } cout << minval << endl; return 0; }