#include using namespace std; #define rep(i,a,b) for(int i=a;i plus, minus; rep(i, 0, M) { int d; cin >> d; if (d == 0) N--; else if (d < 0) minus.push_back(-d); else plus.push_back(d); } if (N <= 0) return 0; minus.push_back(0); plus.push_back(0); sort(minus.begin(), minus.end()); sort(plus.begin(), plus.end()); int ans = INT_MAX; rep(i, 0, N + 1) { if (plus.size() <= i) continue; if (minus.size() <= N - i) continue; int c = plus[i] + minus[N - i] + min(plus[i], minus[N - i]); ans = min(ans, c); } return ans; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; while (cin >> N >> M) { cout << solve(N, M) << endl; } }