import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static HashMap hm = new HashMap(); static boolean[] primes; static long longestSequence(long[] a, long max) { long total = 0; getPrimes(max); for (int i = 0; i < a.length; i++) { total += longestSequence(a[i]); } return total; } private static void getPrimes(long max) { int n = (int) Math.sqrt(max) + 2; primes = new boolean[n]; Arrays.fill(primes, true); for (int p=2; p*p<=n; p++) { // If prime[p] is not changed, then it is a prime if (primes[p] == true) { // Update all multiples of p for (int i=p*2; i< n; i += p) primes[i] = false; } } } private static long longestSequence(long l) { if (l == 1) return 1; if (l == 2) return 3; if (hm.containsKey(l)) return hm.get(l); long total = 1; for (int i = 2; Math.sqrt(l) + 1 >= i; i++) { if (primes[i]) { if (l % i == 0) { total = l + longestSequence(l / i); break; } } } if (total == 1) { // number is prime total += l; } hm.put(l, total); return total; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] a = new long[n]; long max = Long.MIN_VALUE; for(int a_i = 0; a_i < n; a_i++){ a[a_i] = in.nextLong(); if (a[a_i] > max) max = a[a_i]; } long result = longestSequence(a, max); System.out.println(result); in.close(); } }