import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSingle(long a){ TreeMap factors = new TreeMap<>(); while (a > 1){ long i = 2L; boolean change = false; while (i <= Math.sqrt(a) + 1){ if (a%i == 0){ a = a/i; change = true; if (factors.containsKey(i)){ factors.put(i, factors.get(i) + 1); }else{ factors.put(i, 1L); } break; }else{ i++; } } if (!change){ if (factors.containsKey(a)){ factors.put(a, factors.get(a) + 1); }else{ factors.put(a, 1L); } a = 0; } } long total = 1L; long last = 1L; while(!factors.isEmpty()){ long f = factors.lastKey(); long reps = factors.get(f); factors.remove(f); while(reps > 0){ total += last * f; last = last * f; reps--; } } return total; } static long longestSequence(long[] a) { long total = 0L; for (int i = 0; i < a.length; i++){ long result = longestSingle(a[i]); total += result; //System.out.println(result); } 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(); } }