N, M = map(int, input().split(' ')) D = [int(input()) for i in range(M)] D.sort() ans = 1000000000 for i in range(0, len(D) - N): t = D[i: i + N] ta = 0 for j in range(len(t)): ta = min(abs(t[0]) + abs(t[0] - t[-1]), abs(t[-1]) + abs(t[0] - t[-1])) if ta < ans: ans = ta print(ans)