str_N, str_M = input().split(" ") N = int(str_N) M = int(str_M) Ds = [] for i in range(M): Ds.append(int(input())) Ds.sort() ans = [] for i in range(M-N): max_value = max(Ds[i:i+N]) min_value = min(Ds[i:i+N]) if max_value >= 0 and min_value >= 0: ans.append(max_value) continue if max_value >= 0 and min_value < 0: ans.append(min(max_value * 2 + -1 * min_value, max_value + -1 * min_value * 2)) continue if max_value < 0 and min_value < 0: ans.append(-1 * min_value) print(min(ans))