public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()){ int ans=0; int n=scanner.nextInt(); int [] array=new int[n]; for (int i = 0; i < n; i++) { array[i]=scanner.nextInt(); } Arrays.sort(array); for (int i = 0,flag=0,add=0; i < array.length; i++) { if(array[i]<=flag-2){ flag-=2; } if (array[i]>flag){ add=(array[i]-flag)/2+(array[i]-flag)%2; flag+=add*2; ans+=add; } flag+=2; } System.out.println(ans); } } }