using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long longestSequence(long[] a) { long sum = 0; for (int i = 0; i < a.Length; i++) { sum += longestSequence(a[i]); } return sum; // Return the length of the longest possible sequence of moves. } static long longestSequence(long a) { if (a == 1) return 1; long divisor = 2; long half = a / 2; long max = a + 1; while (divisor <= half) { if(a % divisor == 0) { var temp = 1 + (a / divisor) * longestSequence(divisor); if (temp > max) max = temp; } divisor++; } return max; //if(a % 2 == 0) //{ // return 2 * longestSequence(a / 2); //} //return 2 * longestSequence((a - 1) / 2) + 1; // Return the length of the longest possible sequence of moves. } 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); Console.ReadKey(); } }