import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a, int n) { // Return the length of the longest possible sequence of moves. long count=0; for(int i=0;i2) { flag = isPrime(temp); if(flag == true) { break; } long max = greatest(temp); temp /= max; long k = prev_max*max; count += k; prev_max = k; } count += a[i] + 1; } } return count; } static long greatest(long n) { long maxPrime = 2; while (n % 2 == 0) n >>= 1; for (int i = 3; i <= Math.sqrt(n); i += 2) { while (n % i == 0) { maxPrime = i; n = n / i; } } if (n > 2) maxPrime = n; return maxPrime; } static boolean isPrime(long n) { if (n <= 1) return false; if (n <= 3) return true; // This is checked so that we can skip // middle five numbers in below loop if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] a = new long[n]; for(int a_i = 0; a_i < n; a_i++){ a[a_i] = in.nextLong(); } long result = longestSequence(a, n); System.out.println(result); in.close(); } }