using System; using System.Linq; using System.Collections.Generic; class No693{ static void Main(){ var a=Int32.Parse(Console.ReadLine()); var b=Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).OrderBy(x=>x).ToList(); var c=0; for(int i=0;i1){ b[i+1]+=(b[i]-1); c=b[i]-1; b[i]=1; } } Console.WriteLine(c); } }