using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long seqCount = 0; for(int i = 0; i< a.Count(); i++){ seqCount += calcSeq(a[i]); } return seqCount; } static long calcSeq(long a){ long temp_a = a; long seqCount = a; long smallestPrimeFactor = 0; while (temp_a > 1){ //Console.WriteLine("BEFORE temp_a={0}, spf={1}, sc={2}", temp_a, smallestPrimeFactor, seqCount); smallestPrimeFactor = calcSmallestPrimeFactor(temp_a); //Console.WriteLine("AFTER temp_a={0}, spf={1}, sc={2}", temp_a, smallestPrimeFactor, seqCount); temp_a = temp_a / smallestPrimeFactor; seqCount += temp_a; } return seqCount; } static long calcSmallestPrimeFactor(long temp_a){ long retVal = 0; if(temp_a % 2 == 0) return 2; for(long i = 3; i<= Math.Sqrt(temp_a); i+=2){ if(i%5000000 == 0 ) Console.WriteLine("i={0}", i); if(temp_a % i == 0){ retVal = i; break; } } if (retVal == 0) retVal = temp_a; //Console.WriteLine("retVal={0}", retVal); return retVal; } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] a_temp = Console.ReadLine().Split(' '); long[] a = Array.ConvertAll(a_temp,Int64.Parse); long result = longestSequence(a); Console.WriteLine(result); } }