#!/bin/ruby def moves(x) factors = [] while x % 2 == 0 factors << 2 x /= 2 end sqrt = Math.sqrt(x) i = 3 while i <= sqrt while x % i == 0 factors << i x /= i end i += 2 end factors << x if x > 2 ans, z = 1, nil factors.reverse_each do |f| if z.nil? z = f else z *= f end ans += z end ans end def longestSequence(a) result = 0 a.each do |x| result += moves(x) end result end n = gets.strip.to_i a = gets.strip.split(' ').map(&:to_i) puts longestSequence(a)