import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class Solution{ public static List primeList; public static void main(String[] args) { primeList = sieveOfEratosthenes(100000); // Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] nums = new int[n]; for(int i = 0; i < n; i++){ nums[i] = in.nextInt(); } int ans = 0; for(int i = 0; i < n; i++) { int r = 1; if(nums[i] == 1){ ans = 1; }else{ ans += nums[i] + 1; } while (!isPrime(nums[i]) && nums[i] > 1) { int fact = largestFactor(nums[i]); r = (nums[i] / fact) * r; ans += r; nums[i] = fact; } } System.out.println(ans); } public static int largestFactor(int n){ int fact = 1; for(int i = 0; i < primeList.size() && primeList.get(i) <= n / 2; i++){ if(n % primeList.get(i) == 0){ fact = primeList.get(i); break; } } if(fact != 1){ if(!isPrime(n / fact)){ fact = n / fact; int d = Integer.highestOneBit(fact); while(d > 1){ if(n % d == 0){ fact = d; break; } d = d >> 1;} } } return fact; } public static boolean isPrime(int n){ if(n <= 1) return false; if(n <= 3) return true; if(n % 2 == 0 || n % 3 == 0) return false; for(int i = 5; i * i <= n; i += 6){ if(n % i == 0 || n % (i + 2) == 0) return false; } return true; } public static List sieveOfEratosthenes(int n){ boolean[] primes = new boolean[n + 1]; Arrays.fill(primes, true); primes[0] = false; primes[1] = false; List res = new ArrayList<>(); for(int i = 2; i * i <= n; i++){ if(primes[i]) { res.add(i); for (int j = 2 * i; j <= n; j += i) { primes[j] = false; } } } return res; } }