import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static List longestSequence(int n) { boolean[] isPrime = new boolean[n]; Arrays.fill(isPrime,true); isPrime[1] = false; for (int i=2; i*i < n; i++) if (isPrime[i]) for (int j=i*i; j < n; j+=i) isPrime[j] = false; List result = new ArrayList(n / 4); for(int i=2; i < n; i++){ if(isPrime[i]){ result.add(i); } } return result; } static long longestSequence(long[] a) { List primes = longestSequence(Integer.MAX_VALUE / 256); //System.out.println("P ready"); // Return the length of the longest possible sequence of moves. long sum = 0; for(int i=0; i=0){ //System.out.println("Rem:"+ reminder +" parts:"+prev_parts); if(reminder == 1){ cur_sum += prev_parts; break; } if(reminder % primes.get(k) == 0){ cur_sum += prev_parts; //System.out.println("Ok div:"+ primes.get(k)+" c sum:"+cur_sum); prev_parts = prev_parts * primes.get(k); reminder = reminder / primes.get(k); } else { k--; } } //System.out.println("Fin cur:"+ cur_sum); sum += cur_sum; } return sum; } 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); System.out.println(result); in.close(); } }