import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static Map numMap = new HashMap<>(); static long calc(long n) { if (n == 1) { return 1; } if (numMap.containsKey(n)) { return numMap.get(n); } if (n%2 == 0) { long res = n + calc(n/2); numMap.put(n, res); return res; } else { for (int i = 3; i <= Math.sqrt(n); i++) { if (n % i == 0) { long res = n + calc(n/i); numMap.put(n, res); return res; } } } numMap.put(n, n+1); return n+1; } static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. numMap.put((long)1, (long)1); long total = 0; for (int i = 0; i < a.length; i++) { total+= calc(a[i]); } return total; } 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(); } }