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 //////////////////// const BigNumber = require('bignumber.js'); const cache = []; const lowestDivisor = (number) => { for (let i = new BigNumber(2); i.lessThan(number.dividedBy(2)); i = i.plus(1)) { if (number.modulo(i).isZero()) { return i; } } return new BigNumber(1); } const stickSequence = (stick) => { let result; if (cache[stick.toString()] !== undefined) { return cache[stick.toString()]; } else if (stick.equals(1)) { // can only eat result = new BigNumber(1); } else if (stick.modulo(2).isZero()) { // shortcut for evens result = (stick).plus(stickSequence(stick.dividedBy(2))); } else { const lowest = lowestDivisor(stick); if (lowest.equals(1)) { // is prime result = stick.plus(1); } else { result = (stick).plus(stickSequence(stick.dividedBy(lowest))); } } cache[stick.toString()] = result; return result; } function longestSequence(a) { return a.reduce((sum, curr) => sum.plus(stickSequence(curr)), new BigNumber(0)); } function main() { var n = parseInt(readLine()); a = readLine().split(' '); a = a.map(v => new BigNumber(v)); var result = longestSequence(a); process.stdout.write("" + result.toString() + "\n"); }