import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static List primes = new LinkedList<>(); static { boolean[] notPrime = new boolean[10000001]; notPrime[0] = true; notPrime[1] = true; for (int i = 2; i < Math.sqrt(10000000); i++) { if (!notPrime[i]) { for (int j = i+i; j < 10000001; j+=i) { notPrime[j] = true; } primes.add((long)i); } } for (int i = (int)Math.sqrt(10000000); i < 10000001; i++) { if (!notPrime[i]) { primes.add((long)i); } } } static boolean isPrime(long n) { if (n <= 1) { return false; } if (n == 2) { return true; } Iterator iter = primes.iterator(); long prime = iter.next(); while (iter.hasNext() && prime <= n) { if (n % prime == 0) { return n == prime; } prime = iter.next(); } if (n % prime == 0) { return n == prime; } return true; } static List primeFactors(long a) { if (isPrime(a)) { return Collections.singletonList(a); } List res = new LinkedList<>(); Iterator iter = primes.iterator(); long prime = iter.next(); long orig = a; while (a > 1) { if (a % prime == 0) { res.add(prime); a = a / prime; } else if (prime > Math.sqrt(orig)) { res.add(a); break; } else if (iter.hasNext()) { prime = iter.next(); } else { break; } } Collections.sort(res); return res; } static long countMoves(long a) { long moves = 1; List factors = primeFactors(a); Collections.reverse(factors); long product = 1; for (long factor : factors) { product *= factor; moves += product; } return moves; } static long longestSequence(long[] a) { long moves = 0; for (long length : a) { moves += countMoves(length); } return moves; } 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(); } }