def solve(): N, M = map(int, input().split()) D = [] for i in range(M): D.append(int(input())) D.sort() ans = 1e9 for l in range(M): r = l + N - 1 if r >= M: break if D[l] <= 0 and D[r] <= 0: ans = min(ans, -D[l]) elif D[l] >= 0 and D[r] >= 0: ans = min(ans, D[r]) else: ans = min(ans, min(-D[l] * 2 + D[r], -D[l] + D[r] * 2)) print(ans) if __name__ == '__main__': solve()