process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// var pasos = 0; var totalPasos = 0; var memory = {}; function longestSequence(originals, chocolate, coloumns) { if(memory[chocolate]){ pasos += memory[chocolate] * coloumns; return; } if(chocolate == 1) { pasos = 1; return; } if(chocolate%2) { pasos = chocolate +1; return; } if(chocolate == 2){ pasos += originals + coloumns; memory[originals] = pasos; return; } var type = (chocolate/2) % 2; if(type){ // Barra con mitad impar pasos += coloumns; coloumns = (coloumns* (chocolate/2)); chocolate /= (chocolate/2); //while(chocolate%2 == 0){ // coloumns *= 2; //chocolate /= 2; //} // return pasos + originals; } else { //while(chocolate%2 == 0){ pasos += coloumns; coloumns *= 2; chocolate /= 2; //} //return pasos + originals; } return longestSequence(originals, chocolate, coloumns); } function main() { var n = parseInt(readLine()); var chocolates = readLine().split(' '); chocolates = chocolates.map(Number); for(var i = 0; i < chocolates.length; i++){ pasos = 0; longestSequence(chocolates[i], chocolates[i], 1); totalPasos += pasos; } process.stdout.write("" + totalPasos + "\n"); }