import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Solution { private static long[] primes; static { precalc(1000000); } private static void precalc(int limit) { boolean[] booleans = new boolean[limit]; for (int i = 0; i < limit; i++) { booleans[i] = false; } booleans[2] = booleans[3] = true; int x2, y2; int sqr_lim = (int) Math.sqrt(limit); int n; x2 = 0; for (int i = 1; i <= sqr_lim; i++) { x2 += 2 * i - 1; y2 = 0; for (int j = 1; j <= sqr_lim; j++) { y2 += 2 * j - 1; n = 4 * x2 + y2; if (n <= limit && (n % 12 == 1 || n % 12 == 5)) { booleans[n] = !booleans[n]; } n -= x2; if (n <= limit && n % 12 == 7) booleans[n] = !booleans[n]; n -= 2 * y2; if ((i > j) && (n <= limit) && (n % 12 == 11)) booleans[n] = !booleans[n]; } } for (int i = 5; i < sqr_lim; i++) { if (booleans[i]) { n = i * i; for (int j = n; j < limit; j += n) { booleans[j] = false; } } } List listPrimes = new ArrayList<>(); for (int i = 0; i < limit; i++) { if (booleans[i]) listPrimes.add(i); } primes = new long[listPrimes.size()]; for (int i = 0; i < primes.length; i++) { primes[i] = listPrimes.get(i); } } static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long result = 0L; for (long numOfSticks : a) { long nextBlockSize = numOfSticks; long operations = 1; while (nextBlockSize > 1) { if (Arrays.binarySearch(primes, nextBlockSize) >= 0) { result += operations; break; } else { for (int i = primes.length - 1; i >= 0; i--) { if (primes[i] <= nextBlockSize && nextBlockSize % primes[i] == 0) { result += operations; nextBlockSize = nextBlockSize / primes[i]; operations = operations * primes[i]; break; } } } } result += numOfSticks; } return result; } 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(); } }