import math def min_len(pos, Ds, N): length = max([math.fabs(i) for i in Ds]) next_i = 0 for i in range(len(Ds)): tmp_length = math.fabs(pos - Ds[i]) if length > tmp_length: length = tmp_length next_i = i if N == 1: return int(length) next_pos = Ds[next_i] Ds.pop(next_i) return int(length) + min_len(next_pos, Ds, N-1) str_N, str_M = input().split(" ") N = int(str_N) M = int(str_M) Ds = [] for i in range(M): Ds.append(int(input())) print(min_len(0, Ds, N))