import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(List a) { int total = 0; while (a.size() > 0) { Long e = a.remove(0); if (e == 1) { total++; continue; } if (e == 2) { total++; a.add(1L); a.add(1L); continue; } for (int x = 0; x < e / 2; x++) { a.add(e / (e / 2)); } total++; if (e % 2 != 0) { a.add(1L); } } return total; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); List a = new ArrayList<>(); for (int a_i = 0; a_i < n; a_i++) { Long x = in.nextLong(); a.add(x); } long result = longestSequence(a); System.out.println(result); in.close(); } }