import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static long longestSequence(long[] a) { long total = 0; for (int i = 0; i < a.length; ++i) { total += F(a[i]); } return total; } private static long F(long x) { Set dividers = dividers(x); if (dividers.isEmpty()) return x > 1 ? x + 1 : 1; long max = 0; int bestDivider = 0; for (Integer divider : dividers) { long f = 1 + F(x / divider) * divider; if (max < f) { max = f; bestDivider = divider; } } //System.out.println("Best split for " + x + ": " + bestDivider + " parts of size " + x / bestDivider); return max; } private static Set dividers(long x) { Set dividers = new HashSet<>(); if (x > 2) { int sqr = (int) (Math.sqrt(x) + 1); for (int i = 2; i <= sqr && i < x; ++i) { if (x % i == 0) { dividers.add(i); dividers.add((int) (x / i)); } } } return dividers; } 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(); } }