#include #include #include using namespace std; int abs(int a){ return 0 <= a ? a : -a; } int main(){ int n, m; cin >> n >> m; vector l, r; while(m--){ int d; cin >> d; (d < 0 ? l : r).emplace_back(abs(d)); } l.emplace_back(0); r.emplace_back(0); sort(l.begin(), l.end()); sort(r.begin(), r.end()); int ans = 1 << 30; for(int i = 0; i < l.size(); i++) if(n - i < r.size()){ int dist = min(2 * l[i] + r[n - i], l[i] + 2 * r[n - i]); ans = min(ans, dist); } cout << ans << endl; }