def main(): N, M = map(int, input().split()) l = [int(input()) for _ in range(M)] if 0 not in l: N += 1 l.append(0) l.sort() ans = 10 ** 10 for i in range(len(l) - N): a = l[i:i + N] if 0 not in a: continue m = [i for i in a if i < 0] p = max(a) if m: if abs(min(m)) < p: ans = min(ans, abs(min(m)) * 2 + p) else: ans = min(ans, abs(min(m)) + p * 2) else: ans = min(ans, p) print(ans) if __name__ == '__main__': main()