import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.Stack; public class Solution { static List primes; static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long sum = 0; for (long alpha : a) { sum += solution(alpha) + alpha; } return sum; } static long solution(long a) { Stack primefactors = new Stack(); int max = (int) Math.round(Math.sqrt(a)); for (long x : primes) { while (a % x == 0) { primefactors.add(x); a /= x; } if (x > max) break; } if (a > 1) primefactors.add(a); long sum = 0; long f = 1; while (!primefactors.isEmpty()) { sum += f; f *= primefactors.pop(); } return sum; } static List sieve(int n) { List primes = new ArrayList(); boolean[] notprime = new boolean[n]; notprime[0] = notprime[1] = true; for (int i = 2; i < n; i++) { if (!notprime[i]) { primes.add((long) i); for (int j = i + i; j < n; j += i) notprime[j] = true; } } return primes; } public static void main(String[] args) { Scanner in = new Scanner(System.in); primes = sieve(1000000); 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(); } }