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. var moves = 0; for (var i=0; i1){ div = findDiv(a[i]); console.log(div); moves += tmpMoves; a[i] = a[i]/div; tmpMoves = tmpMoves*div; } moves += tmpMoves;*/ moves += getMoves(a[i]); } } return moves } function isPrime(value) { if (value == 2){ return false; } if(value>=9){ for(var i = 3; i < Math.sqrt(value); i+=2) { if(value % i === 0) { return false; } } return value > 1; } else{ for(var i = 3; i < value; i++) { if(value % i === 0) { return false; } } return value > 1; } } function getMoves(value){ var arr=[]; while (value%2==0){ value = value/2; arr.push(2); } if (value==1){ } else { var loop = true; while(loop){ if(value>=9){ for(var i = 3; i <= Math.sqrt(value); i+=2) { if(value % i === 0) { value = value/i arr.push(i); break; } if(Math.sqrt(value)-i<2){ loop=false; } } }else{ for(var i = 3; i <= value; i+=2) { if (value==i){ loop = false; break; } if(value % i === 0) { value = value/i arr.push(i); break; } } } } } arr.push(value); var tmp=1; var v = 1; for (var i =arr.length-1; i>=0;i--){ tmp = tmp*arr[i]; v += tmp } return v; } function findDiv(value){ var tmpEven; if (value == 2){ return value; } if (value%2==0){ while (value%2==0){ value = value/2 } if (value==1){ return 2; } else { var loop = true; while(loop){ for(var i = 3; i <= value; i+=2) { if (i==value){ loop = false; break; } if(value % i === 0) { if(value/i>i){ value = value/i }else{ value = i } break; } } } return value; } } if(value>9){ var loop = true; while(loop){ for(var i = 3; i <= value; i+=2) { if (i==value){ loop = false; break; } if(value % i === 0) { if(value/i>i){ value = value/i }else{ value = i } break; } } } return value; } else { for(var i = 3; i <= value; i+=2) { if(value % i === 0) { if(value/i>i){ return value/i } return i; } } if(value%2==0){ return 2; } return value; } } function main() { var n = parseInt(readLine()); a = readLine().split(' '); a = a.map(Number); var result = longestSequence(a); process.stdout.write("" + result + "\n"); }