import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static List primes = new ArrayList<>(); static int primeIndex = 0; static long primeCandidate = 3; static { primes.add(2L); } private static void startOverPrime() { primeIndex = 0; } private static long nextPrime() { if (primeIndex < primes.size()) { return primes.get(primeIndex++); } else { long nextPrime = findNextPrime(); primeIndex++; primes.add(nextPrime); return nextPrime; } } private static long findNextPrime() { long root = Double.valueOf(Math.sqrt(primeCandidate)).longValue(); boolean prime = false; while(!prime) { for (long p : primes) { if (primeCandidate % p == 0) break; else if (p > root) { prime = true; break; } } primeCandidate += 2; } return primeCandidate - 2; } static long longestSequence(long[] a) { long sum = 0; for (long value : a) { startOverPrime(); List primes = new ArrayList<>(); long prime = nextPrime(); while(value > 1) { if (value % prime == 0) { primes.add(prime); value /= prime; } else if (prime * prime > value) { // value is prime, but not found yet primes.add(value); break; } else { prime = nextPrime(); } } Collections.reverse(primes); long rate = 1; for (long p : primes) { sum += rate; rate *= p; } sum += rate; } return sum; } 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(); } }