import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int M = sc.nextInt(); int[] pos = new int[M]; for(int i = 0; i < M; i++){ pos[i] = sc.nextInt(); } int answer = Integer.MAX_VALUE; for(int fst = 0; fst <= M - N; fst++){ final int snd = fst + N - 1; answer = Math.min(answer, (Integer.signum(pos[fst]) == Integer.signum(pos[snd])) ? Math.max(Math.abs(pos[fst]), Math.abs(pos[snd])) : (Math.min(Math.abs(2 * pos[fst]) + Math.abs(pos[snd]), Math.abs(pos[fst]) + 2 * Math.abs(pos[snd])))); } System.out.println(answer); } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public void close() throws IOException { br.close(); } } }