import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static Map answers; static List getDivisors(long x){ List divisors = new ArrayList<>(); for(long i=2;i<=Math.sqrt(x);++i){ if(x%i==0){ divisors.add(i); divisors.add(x/i); } } return divisors; } static long getMax(long a){ if(a==1){ return 1; } List divisors = getDivisors(a); if(answers.get(a) != null){ return answers.get(a); } if(divisors.size() == 0){ answers.put(a,new Long(a+1)); }else{ long max =-1; for(long divisor : divisors){ max = Long.max(1+((a/divisor)*(getMax(divisor))),max); } answers.put(a, Long.max(max,a+1)); } return answers.get(a); } static long longestSequence(long[] a) { answers = new HashMap<>(); long ans = 0; for(long x : a){ ans += getMax(x); } return ans; } 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(); } }