import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static Map subproblems = new HashMap<>(); static long longestSequence(long[] a) { int n = a.length; long result = 0; if(n == 0) return 0; subproblems.put(0L, 0L); subproblems.put(1L, 1L); subproblems.put(2L, 3L); // Return the length of the longest possible sequence of moves. for(int i = 0; i < n; i++) { result += split(a[i]); } return result; } static long split(long n) { long max = Long.MIN_VALUE; if(subproblems.containsKey(n)) { //System.out.println("n = " + n + ", containsKey return " + subproblems.get(n)); return subproblems.get(n); } else { long newN = 0; long i; long tempResult = 0; for(i = 2; i <= n; i++) { if(n % i == 0){ newN = n / i; tempResult = i * split(newN) + 1; if(tempResult > max) { max = tempResult; } // System.out.println("i = " + i + ", tempResult = " + tempResult); } } if(max > Long.MIN_VALUE) { // System.out.println("i = " + i + ", save n = " + n + ", max = " + max); subproblems.put(n, max); } } return subproblems.get(n); } 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(); } }