#include int n, m, d[1000]; int e[1000]; void sort(int l, int r) { if(r - l < 2) { return; } int b = (l + r) / 2; sort(l, b); sort(b, r); int ll = l; int rr = b; int c = l; while( ! (ll == b && rr == r) ) { bool flag; if( rr == r ) { flag = true; } else if( ll == b ) { flag = false; } else { flag = d[ll] <= d[rr]; } if(flag) { e[c] = d[ll]; ll++; } else { e[c] = d[rr]; rr++; } c++; } for(int i = l; i < r; i++) { d[i] = e[i]; } return; } int main() { scanf("%d%d", &n, &m); for(int i = 0; i < m; i++) { scanf("%d", &d[i]); } sort(0, m); int min = 30001; for(int i = 0; i + (n - 1) < m; i++) { int a = d[i], b = d[i + (n - 1)]; if(a <= 0 && b <= 0) { if(-a < min) { min = -a; } } else if(0 <= a && 0 <= b) { if(b < min) { min = b; } } else { int c = -a * 2 + b; if(c < min) { min = c; } c = -a + b * 2; if(c < min) { min = c; } } } printf("%d\n", min); return 0; }