N, m = map(int, input().split()) P, M = [0], [] for i in range(m): D = int(input()) if D >= 0: P.append(D) else: M.append(D) inf = 10 ** 18 M.append(0) M.reverse() while len(P) < N + 1: P.append(inf) while len(M) < N + 1: M.append(-inf) ans = inf for i in range(N + 1): ans = min(ans, 2 * P[i] - M[N - i]) ans = min(ans, -2 * M[i] + P[N - i]) print(ans)