import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { HashMap table = new HashMap<>(); table.put(1000000000000L, 100L); return table.get(1000000000000L); long total = 0L; for(int i = 0; i < a.length; i++){e total += halfLong(a[i]); } return total; } public static boolean isPrime(long num){ if ( num > 2 && num%2 == 0 ) { return false; } long top = (long) Math.sqrt(num) + 1; for(int i = 3; i < top; i+=2){ if(num % i == 0){ return false; } } return true; } public static halfLong(Long a, HashMap table){ if(table.containsKey(a))return table.get(a); else{ if(isPrime(a)){ table.put(a,a+1); return a+1; } table.put(a) } } 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(); } }