import java.io.*; import java.security.SecureRandom; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { long sum = 0; for(long val: a){ sum += solve(val); } return sum; } private final static BigInteger ZERO = new BigInteger("0"); private final static BigInteger ONE = new BigInteger("1"); private final static BigInteger TWO = new BigInteger("2"); private final static SecureRandom random = new SecureRandom(); public static BigInteger rho(BigInteger N) { BigInteger divisor; BigInteger c = new BigInteger(N.bitLength(), random); BigInteger x = new BigInteger(N.bitLength(), random); BigInteger xx = x; // check divisibility by 2 if (N.mod(TWO).compareTo(ZERO) == 0) return TWO; do { x = x.multiply(x).mod(N).add(c).mod(N); xx = xx.multiply(xx).mod(N).add(c).mod(N); xx = xx.multiply(xx).mod(N).add(c).mod(N); divisor = x.subtract(xx).gcd(N); } while((divisor.compareTo(ONE)) == 0); return divisor; } static Map> rhoMap = new HashMap<>(); public static Set factor(BigInteger N) { if(rhoMap.containsKey(N)){ return rhoMap.get(N); } if (N.compareTo(ONE) == 0) { return new HashSet<>(); } Set factors = new HashSet<>(); if (N.isProbablePrime(20)) { factors.add(N); rhoMap.put(N, factors); return factors; } BigInteger divisor = rho(N); factors.addAll(factor(divisor)); factors.addAll(factor(N.divide(divisor))); rhoMap.put(N, factors); return factors; } static Map map = new HashMap<>(); public static long solve(long val){ if(map.containsKey(val)){ return map.get(val); } long sum = 0; if ( val > 0){ boolean found = false; for(BigInteger primeBigInt: factor(BigInteger.valueOf(val))){ long prime = primeBigInt.longValue(); long currentSum = 0; if( val % prime == 0){ long divisor = val / prime; found = true; currentSum++; if(val == prime){ currentSum += val; }else{ long firstSum = 0; firstSum += (solve(prime) * divisor); long secondSum = 0; secondSum += ( solve(divisor) * prime); currentSum += Math.max(firstSum, secondSum); } } sum = Math.max(currentSum, sum); } if(!found){ sum++; } } map.put(val, sum); 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(); } }