import sys def solve(): N, M = map(int, input().split()) Ds = [] for i in range(M): Ds.append(int(input())) Ds.sort() ans = float('inf') for i in range(M - N + 1): ans = min(ans, abs(Ds[i] - Ds[i + N - 1]) + min(abs(Ds[i]), abs(Ds[i + N - 1]))) print(ans) def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None if __name__ == '__main__': solve()