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. Map map = new HashMap<>(); map.put((long) 1, (long) 1); long res = 0; for (long x : a) { res += getMoves(x, map); } return res; } static long getMoves(long x, Map map) { Long count = map.get(x); if (count != null) { return count; } count = x + 1; for (long i = 2; i * 2 <= x; i++) { if (x % i == 0) { count = Math.max(count, i * getMoves(x / i, map) + 1); } } map.put(x, count); return count; } 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(); } }