N,M = map(int,raw_input().split(" ")) D = [input() for i in range(M)] ans = [] for i in range(M-N+1): v = D[i:i+N] vmin = v[0] vmax = v[-1] if vmin > 0: ans.append(vmax) elif vmax < 0: ans.append(-vmin) else: p = abs(vmax) if (abs(vmin) > abs(vmax)) else abs(vmin) ans.append(abs(vmax) + abs(vmin) + p) print min(ans)