import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static TreeSet getPrimes(long max){ TreeSet primeFactors = new TreeSet(); int max_sqrt = (int)Math.sqrt((double)max) + 1; //System.out.println("max_sqrt = " + max_sqrt); boolean[] prime_sieve = new boolean[max_sqrt+1]; // first, assume everything (above 1) is prime for (int i = 2; i <= max_sqrt; i++ ){ prime_sieve[i] = true; } // we know 2 really is a prime int prime = 2; // add it to the list of divisors primeFactors.add(prime); //System.out.println("adding 2 to the list of factors"); while (prime <= max_sqrt){ // cross out all the multiples of divisor (starting with 2* divisor) for (int i = 2*prime; i <= max_sqrt; i+= prime){ //System.out.println("crossing out " + prime_sieve[i]); prime_sieve[i] = false; } // then start searching up for the next divisor that's still true prime++; while(prime <= max_sqrt && prime_sieve[prime] == false){ prime++; } if(prime <= max_sqrt){ primeFactors.add(prime); //System.out.println("adding " + prime + " to the list of factors"); } } return primeFactors; } static TreeSet findPrimeDivs(long a, TreeSet candidatePrimes){ TreeSet primeDivs = new TreeSet(); //Iterator candidate = candidatePrimes.descendingIterator(); Iterator iter = candidatePrimes.iterator(); while (iter.hasNext()){ int prime = iter.next(); if (a%prime == 0){ primeDivs.add(prime); } } /* while (candidate.hasNext()){ long div = candidate.next(); if (a % div == 0){ primeDivs.add(div); } } */ return primeDivs; } static long getNumNodes(long a, TreeSet candidatePrimes){ TreeSet primeDivs = new TreeSet(); primeDivs = findPrimeDivs(a, candidatePrimes); Iterator div = primeDivs.descendingIterator(); long result = 1; long mult = 1; //System.out.println("a = " + a); if (!div.hasNext() && a!= 1){ //System.out.println("a has no divisors"); // then a itself must be prime, so result = result + a; } while(div.hasNext()){ int factor = div.next(); a = a/(long)factor; //System.out.println(" factor: " + factor); mult = mult * (long)factor; result = result + mult; while(a % (long)factor == 0){ a = a/(long)factor; //System.out.println(" factor: " + factor); mult = mult * (long)factor; result = result + mult; } } //System.out.println("count for a = " + result); return result; } static long longestSequence(long[] a, long max) { TreeSet candidatePrimes = new TreeSet(); candidatePrimes = getPrimes(max); long result = 0; for (int i = 0; i < a.length; i++){ result += getNumNodes(a[i], candidatePrimes); } return result; // Return the length of the longest possible sequence of moves. } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] a = new long[n]; long max = 0; for(int a_i = 0; a_i < n; a_i++){ a[a_i] = in.nextLong(); if (a[a_i] > max){ max = a[a_i]; } } long result = longestSequence(a, max); System.out.println(result); in.close(); } }