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. var longestSequence = 0L; for (var i = 0; i < a.Length; ++i) { if (a[i] == 1) { longestSequence += 1L; } else { longestSequence += getNumberMoves(a[i]); } } return longestSequence; } static long getNumberMoves(long num) { var moves = num; while (num % 2 == 0) { num /= 2; moves += num; } if (num > 1) { var greatestDivisor = findGreatestNonSelfDivisor(num); while (greatestDivisor > 1) { moves += greatestDivisor; num /= greatestDivisor; greatestDivisor = findGreatestNonSelfDivisor(greatestDivisor); } moves += 1; } return moves; } static long findGreatestNonSelfDivisor(long num) { var divisor = 1; for (var i = 3; i <= Math.Sqrt(num); i = i + 2) { if (num % i == 0) { divisor = i; break; } } return (divisor > 1) ? num / divisor : divisor; } 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); } }