import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Solution { static boolean[] isPrime = new boolean[1000000 + 1]; static { Arrays.fill(isPrime, true); for (int x = 2; x <= 1000000; x++) { if (!isPrime[x]) continue; for (int d = 2; d * x <= 1000000; d++) { isPrime[d * x] = false; } } } static List getPrimes(long v) { List primes = new ArrayList<>(); for (int d = 1000000; d >= 2; d--) { if (isPrime[d]) { while (v % d == 0) { primes.add((long) d); v /= d; } } } if (v > 1) { primes.add(v); } Collections.sort(primes); Collections.reverse(primes); return primes; } static long calc(long a) { long pieces = 1; long res = 0; List primes = getPrimes(a); for (long p : primes) { res += pieces; pieces *= p; } return res + pieces; } static long longestSequence(long[] a) { return Arrays.stream(a).map(Solution::calc).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(); } }