import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { long total = 0; Primes myPrimes = new Primes(); myPrimes.generatePrimes(1000100L); for(int i = 0; i < a.length; ++i){ long n = a[i]; // find smallest factor of n (p) // // repeat long cur = 1; int curPrimeIndex = 0; long curDivisor = 2; while(n>1 && curDivisor < 1000001){ if(n%curDivisor == 0){ n/= curDivisor; cur= curDivisor*cur +1; }else{ curPrimeIndex++; curDivisor = myPrimes.getPrime(curPrimeIndex); } } if(n>1){// big prime leftover cur = n*cur+1; } total+=cur; } return total; } 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(); } } class Primes { ArrayList primes = new ArrayList<>(); long maxTried; HashMap primeToIndex = new HashMap<>(); public Primes() { primes.add(2L); primeToIndex.put(2L, 0); maxTried = 2L; } public void generatePrimes(long size){ ArrayList isPrime = new ArrayList(); for(; isPrime.size() < size+2; ){ isPrime.add(false); isPrime.add(true); } int curIndex = 3; while(curIndex <= size){ while(curIndex < size && !isPrime.get(curIndex)){ curIndex++; } if(curIndex >= size){ break; } int curPrime = curIndex; addPrime(curPrime); for(long i = curPrime*(long)curPrime; i <= size; i+=curPrime){ isPrime.set((int)i, false); } curIndex++; } maxTried = size; //System.out.println(isPrime); //System.out.println(primes); } public long getPrime(int index) { return primes.get(index); } public void addPrime(long i){ primeToIndex.put(i, primes.size()); primes.add(i); } }