import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static ArrayList getComb(ArrayList a) { // Return the length of the longest possible sequence of moves. Collections.sort(a); ArrayList list = new ArrayList<>(); for(int i=0;i 0 && a.get(i) == a.get(i-1) && a.get(i) == a.get(j)) continue; list.add(sum); } } return list; } static ArrayList getPrime(long a) { // Return the length of the longest possible sequence of moves. ArrayList primeList = new ArrayList<>(); primeList.add(2l); for(long i=3;i<=Math.sqrt(a);i = i+2){ boolean isPrime = true; for(int j=0;primeList.get(j)<=Math.sqrt(i);j++){ if(i%primeList.get(j)==0){ isPrime = false; } } if(isPrime)primeList.add(i); } return primeList; } static ArrayList getPrimeFactorMap(long a, ArrayList primeList) { // Return the length of the longest possible sequence of moves. ArrayList flist = new ArrayList<>(); for(int i=0;i< primeList.size() && primeList.get(i)<=Math.sqrt(a);){ if(a%primeList.get(i)==0){ while (a%primeList.get(i)==0){ a = a/primeList.get(i); flist.add(primeList.get(i)); } i=0; }else { i++; } } if(a>1){ flist.add(a); } return flist; } static long longestSequence (long a, Map cache,ArrayList primeList) { // Return the length of the longest possible sequence of moves. if(cache.get(a)!=null) return cache.get(a); long sum = a; ArrayList flist = getComb(getPrimeFactorMap(a, primeList)); for(int i=0;i cache = new HashMap<>(); cache.put(1l,1l); cache.put(2l,3l); long max = Integer.MIN_VALUE; for(long l : a){ max = Math.max(max,l); } ArrayList primeList = getPrime(max); for(long l : a){ sum = sum + longestSequence(l,cache, primeList); } return 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(); /*ArrayList primeList = getPrime(21); System.out.println(primeList); ArrayList flist = getPrimeFactorMap(21,primeList); System.out.println(flist); System.out.println(getComb(flist)); */ } }