#!/usr/bin/env python3 n, m = map(int,input().split()) d = list(sorted(map(lambda _: int(input()), range(m)))) ans = float('inf') for l in range(m - n + 1): r = l + n - 1 if d[l] < d[r] <= 0: acc = - d[l] elif 0 <= d[l] < d[r]: acc = d[r] else: assert d[l] <= 0 <= d[r] acc = max(- d[l], d[r]) + 2 * min(- d[l], d[r]) ans = min(ans, acc) print(ans)