using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { class LongestSequenceFinder { readonly long[] bag; public LongestSequenceFinder(long[] bag) { this.bag = bag; // memory[1] = 1; } public long GetLongestSequence() { long result = 0; foreach (var stick in bag.OrderBy(x => x)) { LinkedList factors = new LinkedList(GetPrimeFactors(stick).OrderByDescending(x => x)); result = result + DetermineLongestStickSequence(factors.First); } return result; } private List GetPrimeFactors(long n) { var primes = new List(); // Print the number of 2s that divide n while (n % 2 == 0) { primes.Add(2); n = n / 2; } // n must be odd at this point. So we can skip // one element (Note i = i +2) for (int i = 3; i <= Math.Sqrt(n); i = i + 2) { // While i divides n, print i and divide n while (n % i == 0) { primes.Add(i); n = n / i; } } if (n > 1) primes.Add(n); return primes; } long DetermineLongestStickSequence(LinkedListNode factor) { if (factor == null) return 1; return 1 + factor.Value * DetermineLongestStickSequence(factor.Next); } } static long longestSequence(long[] a) { var finder = new LongestSequenceFinder(a); return finder.GetLongestSequence(); } 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); } }