n, m = map(int, input().split()) d = [0] * m for i in range(m): d[i] = int(input()) dist = 0 for i in range(n): p = d[i] q = d[i+n-1] if p * q > 0: dist = min(abs(p), abs(q)) else: dist = abs(p) + abs(q) + min(abs(p), abs(q)) print(dist)