#include using namespace std; using ll = long long; using PII = std::pair; using PLL = std::pair; #define rep(i, n) for (int i = 0; i < (int)(n); i++) // #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) // #define DEBUG int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; ifstream in("input.txt"); //for debug cin.rdbuf(in.rdbuf()); //for debug #endif int n, m, d, l, r, ans; cin >> n >> m; vector gabage; rep(i, m) { cin >> d; gabage.push_back(d); } sort(gabage.begin(), gabage.end()); ans = 1e9+7; rep(i, n) { l = gabage[i]; r = gabage[i + n - 1]; if (l * r < 0) ans = min(ans, abs(l) + abs(r) + min(abs(l), abs(r))); else ans = min(ans, max(abs(l), abs(r))); } cout << ans << endl; return 0; }