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 movies(m) { var total = 1; //console.log(m); for(var i = 0; i < m.length - 1; i++) { total = (total * (m[i+1]/m[i]) ) + 1; //console.log(m[i+1], m[i], total); } return total; } function maxMoves(n) { if(n == 1) { return 1; } var f = [1]; for(var i = 2; i <= n/2; i++) { if(n%i == 0) { f.push(i); } } f.push(n); //f.reverse(); var totals = []; for(var i = 1; i < f.length - 1; i++) { var series = [1]; for(var j = i; j < f.length; j++) { var o = n/f[j]; if(f.indexOf(o) >= 0) { if(f[j]%series[series.length - 1] == 0) { series.push(f[j]); } } else { series = null; break; } } if(series) { //console.log('series: ', series, movies(series) ); totals.push(movies(series)); } } //console.log('totals: ', totals); if(totals.length > 0) { totals.sort(function(a, b) { return b - a; }); return totals[0]; } else { return n + 1; } } function longestSequence(a) { var longest = 0; for(var i = 0; i < a.length; i++) { longest += maxMoves(a[i]); //console.log(i, 'longest: ', longest); } return longest; } function main() { var n = parseInt(readLine()); a = readLine().split(' '); a = a.map(Number); var result = longestSequence(a); process.stdout.write("" + result + "\n"); }