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 //////////////////// function longestSequence(a) { // Return the length of the longest possible sequence of moves. const longestMoves = a.map( stick => { if ( stick === 1 ) return 1; let movesSequence = [ stick ]; getLongestMove( stick, movesSequence ); //console.log( `movesSequence = ${ movesSequence }` ); return movesSequence.reduce( ( a, e ) => a + e ); }); //console.log( `longestMoves = ${ longestMoves }`) return longestMoves.reduce( ( a, e ) => a + e ); } function getLongestMove( stick, movesSequence ) { if ( stick === 1 ) return; const subStickLength = getFirstDivisor( stick ); const pieces = stick / subStickLength; movesSequence.push( pieces ); getLongestMove( pieces, movesSequence ); } function getFirstDivisor( stick ) { if ( stick % 2 === 0 ) return 2; const goodEnough = Math.sqrt( stick ); for ( let i=2; i<=goodEnough; i += 1 ) { if ( stick % i === 0 ) return i; } return stick; } function main() { var n = parseInt(readLine()); a = readLine().split(' '); a = a.map(Number); var result = longestSequence(a); process.stdout.write("" + result + "\n"); }