using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; Temoti = long.Parse(Reader.ReadLine()); int boxCount = int.Parse(Reader.ReadLine()); this.BoxList = new long[boxCount]; Total = 0; for(int i=0; ia); if(minVal == minCount) { return this.GetAns(min, q1); } else if(q1 == minCount) { return this.GetAns(min, q2); } else if(q2 == minCount) { return this.GetAns(q1, q3); } else if(q3 == minCount) { return this.GetAns(q2,max); } else { return this.GetAns(q3, max); } } private long GetCount(long target) { if(target * BoxList.Length > Temoti + Total) { return long.MaxValue; } long ans = 0; foreach (long candy in BoxList) { ans += Math.Abs(candy - target); } return ans; } private long[] BoxList; private long Temoti; private long Total; public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 1000000000 9 0 0 0 0 1000000000 1000000000 1000000000 1000000000 1000000000 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }