using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long GetProduct(List factors) { long rv = 1L; foreach (long f in factors) { rv *= f; } return rv; } static bool factorIsPresent(long candidate, List factors) { bool rv = false; foreach (long present in factors) { if ((candidate % present == 0) && (present != 1L)) { rv = true; break; } } return rv; } static long [] GetFactors(long number) { List factors = new List(); for (long candidate = 2L; candidate <= (number / 2) ; candidate++) { if (((number % candidate) == 0) && ! factorIsPresent(candidate, factors)) { long trial = number; while (trial % candidate == 0) { factors.Add(candidate); trial = trial / candidate; } } if (GetProduct(factors) == number) { break; // we have completed the list } } if (factors.Count == 0) { factors.Add(number); } return factors.ToArray(); } static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long length = 0; foreach (long number in a) { // get the factors long[] factors = GetFactors(number); int lastIndex = factors.Length - 1; if (lastIndex >= 0) { long baseNum = factors[lastIndex]; length += baseNum; for (int i = lastIndex - 1; i >= 0; i--) { baseNum = (baseNum * factors[i]); length += baseNum; } } if (!factors.Contains(1)) { length++; } } return length; } 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); } }