#include #include #include #include using namespace std; using ll = long long; ll n, m, d[1010], e[1010]; int main() { cin >> n >> m; for (int i = 0; i < m; ++i) cin >> d[i]; ll ans = 1 << 30; for (int i = 0; i < m - n + 1; ++i) { ans = min(ans, min(abs(d[i + n - 1]), abs(d[i])) + d[i + n - 1] - d[i]); } cout << ans << endl; return 0; }