using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long moves = 0; foreach(long n in a){ moves += findMoves(n); } return moves; } 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); } static bool IsPowerOfTwo(long x) { return (x & (x - 1)) == 0; } static long findMoves(long n){ if(n == 1){ return 1; } if(IsPowerOfTwo(n)){ return 2*n - 1; } long n1 = HighestPowerof2(n); long n2 = n - n1; return findMoves(n1) + findMoves(n2); } static long HighestPowerof2(long n) { double log = Math.Log(n, 2); double pow = Math.Pow(2, (long)log); /*long p = (int)log2(n); return (int)pow(2, p); */ return (long) pow; } }