import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static boolean isPrime(long n){ if(n==2 || n==3) return true; else if (n==1) return false; for(long i=2;i<=Math.sqrt(n);i++){ if(n%i==0) return false; } return true; } static long leastDivisor(long n){ if (n % 2 == 0) return 2; else{ long squareRootOfn = (long)Math.floor(Math.sqrt(n)); for (long i=3;i<=squareRootOfn;i+=2){ if (n % i == 0) return i; else if (i == squareRootOfn) return 1; } } return 1; } static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. int n=a.length; long total=0; for(int i=0;i0){ if (isPrime(x)){ total+= x+1; break; } else if(x==1){ total+=1; break; } else if(x%2==1){ total+=x; x=x/leastDivisor(x); } else if(x%2==0){ total+=x; x=x/2; } } } 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(); } }