import java.util.Scanner; public class Maina { public static void main (String[]args) { Scanner db=new Scanner (System.in); int a=db.nextInt(); int arr[]=new int [a]; int wee[]=new int [a]; int cou=0; for(int i=0; i<a; i++) arr[i]=db.nextInt(); boolean b=true; while(b) { wee[a-1]=arr[0]/2; for(int i=1; i<a; i++) wee[i-1]=arr[i]/2; for(int i=0; i<a; i++) { arr[i]=arr[i]/2+wee[i]; if(arr[i]%2!=0) { arr[i]++; cou++;} } for(int i=0; i<a-1; i++) { if(arr[i]!=arr[i+1]) break; if(i==a-2) b=false; } } System.out.println(cou); } }