def read_data(): N, M = map(int, input().split()) Ds = [int(input()) for i in range(M)] return N, M, Ds def solve(N, M, Ds): Ds.sort() minmove = float('inf') for i in range(M - N + 1): left = Ds[i] right = Ds[i + N - 1] if left > 0: move = right elif right < 0: move = -left else: move = (right - left) + min(right, -left) minmove = min(minmove, move) return minmove N, M, Ds = read_data() print(solve(N, M, Ds))