import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static Map cache = new HashMap<>(); static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long sum = 0; for (long each : a) { sum += eatOrSplit(each); } return sum; } private static long eatOrSplit(long size) { Long cachedResult = cache.get(size); if (cachedResult != null) { return cachedResult; } if (size == 1) { cache.put(size, 1L); return 1; // eat it } long bestSum = 1 + size; for (long i = 2; i <= Math.sqrt(size); i++) { if (size % i != 0) { continue; } long currCount = i; long currSize = size / currCount; long currSum = currCount * eatOrSplit(currSize) + 1; if (currSum > bestSum) { bestSum = currSum; } currSize = i; currCount = size / currSize; currSum = currCount * eatOrSplit(currSize) + 1; if (currSum > bestSum) { bestSum = currSum; } } cache.put(size, bestSum); return bestSum; } 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(); } }