_ = readline() sticks = parse.(Int, split(readline())) function factorize(n::T) where {T<:Integer} if n == 1 return Dict{T, Int}(1=>1) end # check if power of 2 if (n & (n - 1)) == 0 return Dict{T, Int}(2 => Int(log2(n))) end factors = Dict{T, Int}() currf = 0 while n % 2 == 0 n = n >> 1 currf += 1 end if currf > 0 factors[2] = currf end div = 3 res = 0 sqn = sqrt(n) while (div <= sqn) r, tn = divrem(n, div) while tn == 0 factors[div] = get(factors, div, 0) + 1 res, n = n, r r, tn = divrem(n, div) end div += 2 end if n > 1 factors[n] = get(factors, n, 0) + 1 end return factors end function nmoves(stickf::Dict{T, Int}) where {T<:Integer} n = 1 m = 1 for k in sort(collect(keys(stickf)), rev=true) for i in 1:stickf[k] n *= k m += n end end return m end function main(sticks::Array{Int, 1}) m = count(s-> s==1, sticks) sticks = filter(s-> s>1, sticks) return m + sum(@. nmoves(factorize(sticks))) end println(main(sticks))