using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long move; static long longestSequence(long[] arr) { long a = 0; long b = 0; long c = 0; int count = 1; long len = 0 ; long result = 0; // Return the length of the longest possible sequence of moves. for (int i = 0; i < arr.Length; i++) { len = arr[i]; while (len != 1) { a = len / 2; b = len % 2; c = a + b; count++; move += c; len = c; } result += move + count; } if (arr.Length == 1) { return result; } else { return result + arr.Length; } } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] a_temp = Console.ReadLine().Split(' '); long[] a = Array.ConvertAll(a_temp, Int64.Parse); long result = longestSequence(a); Console.WriteLine(result); } }