import java.util.*; public class Solution { static List primeList = new ArrayList<>(); static Map solutionMap = new HashMap<>(); static long longestSequence(long[] a) { Arrays.sort(a); preparePrimeList(a[a.length-1]); long total = 0; for(int i = 0; i < a.length; i++){ total += getNumberOfMoves(a[i]); } return total; } static long getNumberOfMoves(long a){ if(solutionMap.containsKey(a)){ return solutionMap.get(a); } if(a == 1L){ solutionMap.put(1L,1L); return 1L; } if(primeList.contains(a)){ solutionMap.put(a,a+1L); return a+1L; } long p = getLargestDivisiblePrime(a); return p*(getNumberOfMoves(a/p))+1L; } static boolean isPrime(long a){ if(a == 2L){ return true; } if (a%2L == 0L || a == 1L) { return false; } long top = (long)Math.sqrt(a) + 1L; for(long p:primeList){ if(p > top){ break; }else{ if(a%p == 0L){ return false; } } } return true; } static void preparePrimeList(long a){ for(long i = 2L; i <= a; i++){ if(isPrime(i)){ primeList.add(i); } } } static long getLargestDivisiblePrime(long a){ int i = getStartIndex(a); while(i-->0){ if(a%primeList.get(i) == 0){ return primeList.get(i); } } return primeList.get(0); } static int getStartIndex(long a){ for(int i = 0; i < primeList.size()-1; i++ ){ if(primeList.get(i+1) > a){ return i; } } return primeList.size()-1; } 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(); } }