import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] xy) { long ans=0; long sum=0; for(long a:xy){ if(a==1) sum=1; else{ ArrayList arr=new ArrayList(); while (a%2 == 0) { arr.add((long)2); a/=2; } for (long i = 3; i*i<=a; i = i+2) { // While i divides n, print i and divide n while (a%i == 0) { arr.add(i); a = a/i; } } if(a>2) arr.add(a); Collections.sort(arr,Collections.reverseOrder()); // System.out.println(arr); sum=1; long pro=1; for(Long x:arr){ pro*=x; sum+=pro; }} ans+=sum; } return ans; // Return the length of the longest possible sequence of moves. } 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(); } }