import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static boolean isPerfectSquare(long number) { double sqrt = Math.sqrt(number); int iSqrt = (int) sqrt; return Math.pow(sqrt, 2) == Math.pow(iSqrt, 2); } static boolean isPrime(long number) { if (number == 2) { return true; } else if (number % 2 == 0) { return false; } else { for (int i = 3; i <= (int) Math.sqrt(number); i++) { if (number % i == 0) { return false; } } return true; } } static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long totalMoves = 0; for (int i = 0; i < a.length; i++) { long currentSize = a[i]; long pieces = 1; while (currentSize > 1) { //System.out.println("totalMoves= " + totalMoves + " currentSize=" + currentSize + " pieces=" + pieces); if (isPrime(currentSize)) { // If it's prime, it must be divided into 1 piece lengths totalMoves += pieces; pieces *= currentSize; currentSize = 1; } else { // Find fewest number of pieces to break into if (currentSize % 2 == 1) { // If currentSize is odd, break into largest number of pieces for (int j = 2; j <= (int) Math.sqrt(currentSize); j++) { if (currentSize % j == 0) { totalMoves += pieces; pieces *= j; currentSize /= j; break; } } } else { // If currentSize is even, find largest even divisor long largestEven = 0; for (long j = 3; j <= currentSize / 2; j++) { if (currentSize % j == 0) { if (j % 2 == 0 && (currentSize / j) % 2 == 0) { //System.out.println("In if - currentSize=" + currentSize + " j=" + j); if ((currentSize / j) > 2) { largestEven = Math.max(largestEven, Math.max(j, currentSize / j)); //System.out.println("largestEven=" + largestEven); } } else if (j % 2 == 0) { //System.out.println("In else if"); largestEven = Math.max(largestEven, j); //System.out.println("largestEven=" + largestEven); } else { //System.out.println("In else"); largestEven = Math.max(largestEven, currentSize / j); //System.out.println("largestEven=" + largestEven); } } } totalMoves += pieces; if (largestEven == 0) { largestEven = currentSize / 2; } pieces *= (currentSize / largestEven); currentSize = largestEven; //int startJ = ((int) Math.sqrt(currentSize)) - (currentSize != 4 && isPerfectSquare(currentSize) ? 1 : 0); /* for (int j = startJ; j > 1; j--) { if (currentSize % j == 0) { //System.out.println("j=" + j); totalMoves += pieces; if (j % 2 == 0 && (currentSize / j) % 2 == 0) { //System.out.println("In if"); pieces *= j; currentSize /= j; } else if (j % 2 == 0) { //System.out.println("In else if"); pieces *= (currentSize / j); currentSize = j; } else { //System.out.println("In else"); pieces *= j; currentSize /= j; } break; } } */ /* if ((currentSize / 2) % 2 == 0) { for (int j = 2; j <= (int) Math.sqrt(currentSize); j++) { if (currentSize % j == 0) { totalMoves += pieces; if (j % 2 == 0) { } } } } else { } for (int j = 2; j <= (int) Math.sqrt(currentSize); j++) { if (currentSize % j == 0) { totalMoves += pieces; if (j % 2 == 0) { } } } } for (int j = 2; j <= (int) Math.sqrt(currentSize); j++) { if (currentSize % j == 0) { // Make the even number the currentSize if () totalMoves += pieces; pieces *= j; currentSize /= j; System.out.println("totalMoves=" + totalMoves +" currentSize=" + currentSize + " pieces=" + pieces + " j=" + j); break; } */ } } } totalMoves += pieces; } return totalMoves; } 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(); } }