//http://yukicoder.me/problems/780 #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int N, M; cin >> N >> M; vector D(M); for (int i = 0; i < M; i++) { cin >> D[i]; } sort(D.begin(), D.end()); long long ans = 1000000000; for (int i = 0; i < M - N; i++) { int j = i + N - 1; long long t = 0; if (D[i] <= 0 && 0 <= D[j]) { if (abs(D[i]) < abs(D[j])) t = abs(D[i]) * 2 + abs(D[j]); else t = abs(D[i]) + abs(D[j]) * 2; } else { if (abs(D[i]) < abs(D[j])) t = abs(D[j]); else t = abs(D[i]); } ans = min(ans, t); } cout << ans << endl; return 0; }