using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long longestSequence(long[] a) { long movecount = 0; foreach(long bar in a) { long barSize = bar; long barCount = 1; long moveCount = 0; long bestMoves = 0; movecount += calcSequence(barSize, barCount, moveCount, bestMoves); } return movecount; // Return the length of the longest possible sequence of moves. } static long calcSequence(long barSize, long barCount, long moveCount, long bestMoves) { long size = barSize; long bits = barCount; long moves = moveCount; List possibleDivisors = GenerateDivisors(size); if(size == 1) { return moves + bits; } else { foreach(long divisor in possibleDivisors) { var result = calcSequence(barSize / divisor, barCount * divisor, moveCount + barCount, bestMoves); if (result > bestMoves) { bestMoves = result; } } if(possibleDivisors.Count == 0) { var result = calcSequence(1, barCount * barSize, moveCount + barCount, bestMoves); if (result > bestMoves) { bestMoves = result; } } return bestMoves; } } public static List GenerateDivisors(long number) { var list = new List(); if (number % 2 == 0) list.Add(2); var boundary = (int)Math.Ceiling(Math.Sqrt(number)); for (int i = 3; i <= boundary; i+= 2) { if(number%i == 0) { list.Add(i); } } return list; } 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); } }