import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static Map map = new HashMap<>(); static Map> divisors = new HashMap<>(); static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long ret = 0; for (long n : a) { ret += ls(n); } return ret; } static long ls(long a) { // System.out.println(a); if (a == 1) return 1; if (map.containsKey(a)) return map.get(a); long ret = 1 + a; List ds = getAllDivisors(a); if (ds.size() > 1) { long d = ds.get(ds.size() - 1); ret = Math.max(ret, 1 + d*ls(a/d)); } map.put(a,ret); return ret; } static List getAllDivisors(long a) { if (divisors.containsKey(a)) return divisors.get(a); List ret = new ArrayList<>(); long sq = (long) Math.sqrt(a); for (long i=2L; i<=sq; i++) { if (a%i==0) { ret.add(i); List l = getAllDivisors(a/i); if (l.isEmpty()) { ret.add(a/i); } else { ret.addAll(getAllDivisors(a/i)); } break; } } Collections.sort(ret); divisors.put(a, ret); return ret; } 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(); } }