import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { long result = 0; int [] primes = generateFirstMPrimes(); for (int currentStick = 0; currentStick < a.length; currentStick++) { result += getCurrentStickLongestSequence(a[currentStick], primes); } return result; } private static int[] generateFirstMPrimes() { boolean [] primes = new boolean[1000001]; int primesCount = 0; for (int i = 2; i < 1000001; i++) { if (!primes[i]){ primesCount++; for (int j = i + i; j < 1000001; j+=i) { primes[j] = true; } } } int p [] = new int [primesCount]; primesCount = 0; for (int i = 2; i < 1000001; i++) { if (!primes[i]){ p[primesCount++] = i; } } return p; } private static long getCurrentStickLongestSequence(long stickLength,int [] primes) { if (stickLength == 1) { return 1; } long result = 1 + stickLength; long biggestDivisor = findBiggestDivisor(stickLength, primes); while (biggestDivisor != -1) { result += biggestDivisor; biggestDivisor = findBiggestDivisor(biggestDivisor, primes); } return result; } private static long findBiggestDivisor(long stickLength,int [] primes) { for (int i = 0; i < primes.length && primes[i]* primes[i] <= stickLength; i++) { if (stickLength % primes[i] == 0) { return stickLength / primes[i]; } } return -1; } 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(); } }