from bisect import bisect_left N, M = map(int, input().split()) a = sorted([int(input()) for _ in [0]*M]) bound = bisect_left(a, 0) if a[bound] != 0: a.insert(bound, 0) N += 1 M += 1 ans = float("inf") for i in range(max(0, bound-N+1), min(M-N+1, bound+1)): left, right = abs(a[i]), a[i+N-1] ans = min(ans, left*2+right, left+right*2) print(ans)