import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long sum = 0L; for(long val : a){ sum += longest(val); } return sum; } static Map SEQS = new HashMap<>(); static long longest(long a){ if(a == 1){ return 1; } if(isPrime(a)){ SEQS.put(a, a+1); return a+1; } if(SEQS.get(a) != null){ return SEQS.get(a); } long maxSeq = 0; for(int i = 2; i*2<=a;i++){ if(a%i == 0){ long seq = 1+a/i * longest(i); if(seq > maxSeq){ maxSeq = seq; } } } if(maxSeq == 0){ primes.add(a); maxSeq = a+1; } SEQS.put(a, maxSeq); return maxSeq; } static Set primes = new HashSet<>(); 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(); } public static boolean isPrime(long n){ if(primes.contains(n)){ return true; } if(n == 2L || n == 3L){ primes.add(n); return true; } if(n%2==0){ return false; } for(long i = 3; i< n/2 && i * i < n; i = i +2){ if(n%i == 0){ return false; } } primes.add(n); return true; } }