import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static long[] primes; private static boolean[] isprime; private static final int N = 1000000; private static void sieve() { isprime = new boolean[N]; for (int i = 2; i < N; i++) isprime[i] = true; for (int i = 2; i * i < N; i++) { if (!isprime[i]) continue; for (int j = i * i; j < N; j += i) isprime[j] = false; } int nprime = 0; for (int i = 2; i < N; i++) { if (isprime[i]) nprime++; } primes = new long[nprime]; int id = 0; for (int i = 2; i < N; i++) { if (isprime[i]) primes[id++] = i; } } static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long sum = 0; for (long v : a) { sum += findseq(v); } return sum; } private static long findseq(long val) { if (val == 1L) return 1L; if (val < (long)N && isprime[(int)val]) return val + 1; long val0 = val; long ans = 1; for (long prime : primes) { //System.out.println("val = " + val + ", try prime " + prime); if (val == 1L || prime * prime > val0) break; int cnt = 0; while (val % prime == 0) { val /= prime; cnt++; } //System.out.println("cnt = " + cnt); if (cnt > 0) { long pr = pow(prime, cnt); ans = pr * ans + (pr - 1) / (prime - 1); } } if (val == val0) { // val must be prime return val + 1; } if (val > 1L) { // then val must be larger than N // since we have tried all primes < N to factor it // what does this mean: // now val > N, and val has no prime factors that is < N // assume val is not prime, then it has two primes factors, both > N, this can not be true // val must be prime, and its power must be 1 ans = val * ans + 1; } return ans; } private static long pow(long v, int n) { long ans = 1; while (n != 0) { if (n % 2 == 1) ans *= v; n /= 2; v *= v; } return ans; } 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(); } sieve(); long result = longestSequence(a); System.out.println(result); in.close(); } }