using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; using System.IO; class Magatro { static Scanner sc = new Scanner(); static int N, M; static List L=new List(), R=new List(); static void Main() { N = sc.NextInt(); M = sc.NextInt(); for(int i = 0; i < M; i++) { int next = sc.NextInt(); if (next >= 0) { R.Add(next); } else { L.Add(next); } } R.Sort(); L.Sort((a, b) => a.CompareTo(b) * -1); int ans = int.MaxValue; for(int r = 0; r <= N; r++) { int l = N - r; if (R.Count >= r && L.Count >= l) { if (r == 0) { ans = Math.Min(ans, Math.Abs(L[l - 1])); } else if (l == 0) { ans = Math.Min(ans, R[r - 1]); } else { int min = Math.Min(R[r - 1], Math.Abs(L[l - 1])); int max = Math.Max(R[r - 1], Math.Abs(L[l - 1])); ans = Math.Min(ans, min * 2 + max); } } } Console.WriteLine(ans); } } public class Scanner { public string[] S; private int Index; private char Separator; public Scanner(char separator=' ') { Index = 0; Separator = separator; } public string Next() { string result; if (S == null || Index >= S.Length) { S = Line(); Index = 0; } result = S[Index]; Index++; return result; } private string[] Line() { return Console.ReadLine().Split(Separator); } public int NextInt() { return int.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } }