n = gets.to_i
a = (1..n).map { gets.to_i }.sort
divs = (1..a[-1]).select {|x| a[-1] % x == 0}
s = 0
i = 0
until a.empty?
    x = a.shift
    i += 1 until i == divs.size - 1 or divs[i] >= x
    s += divs[i] - x
end
p s
