using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static bool isDebug = true; static void debug(string msg){ if(isDebug){ Console.WriteLine(msg); } } static long longestSequence(long[] sticks) { // Return the length of the longest possible sequence of moves. long result = 0; foreach(var stick in sticks){ result += longestSequence(stick); } return result; } static long longestSequence(long stick){ if(stick==1){ return 1; } var factors = stick.Factorise(); //debug($"factors of {stick}:"); //factors.ToList().ForEach(x=>debug(x.ToString())); var maxSeq = findSequences(stick, factors.ToList()); //debug($"max for {stick} is {maxSeq}"); return maxSeq; } static long findSequences(long stick, IList factors){ if(stick==factors.First()){ return 1+stick; } var factorsLeft = factors.ToList(); factorsLeft.RemoveAt(0); return 1+factors[0]*findSequences(stick/factors[0], factorsLeft); } 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); } } public static class LongExtensions{ public static IEnumerable Factorise(this long number){ var factors = new List(); var numberLeft = number; for(long i=2;i<=numberLeft;i++){ if(numberLeft%i==0){ factors.Add(i); numberLeft=numberLeft/i; i=1; } } return factors.OrderByDescending(x=>x); } }