import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static ArrayList primes = new ArrayList<>(); static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long moves = 0; long max = 0; for(long piece : a) max = Math.max(max, piece); int limit = (int)Math.sqrt(max) + 2; sieve_primes(limit); for(long piece : a){ moves += get_cost(piece); } return moves; } static void sieve_primes(int limit){ boolean notPrime[] = new boolean[limit]; notPrime[0] = true; notPrime[1] = true; for(int i = 2; i divisors = new LinkedList<>(); int limit = (int)Math.sqrt(piece) + 1; for(int i=0; primes.get(i) < limit; i++){ int p = primes.get(i); while(piece % p == 0){ piece /= p; divisors.addFirst(p); } } if(piece > 1) divisors.addFirst(1); long result = 1; long cuml = piece; for(Integer i : divisors){ cuml *= i; result += cuml; } return result; } 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(); } }