loop do
    n = gets.to_i
    break if n == 0
    s = gets.split.map(&:to_i).inject(:+) * n
    a = gets.split.map(&:to_i).sort.reverse
    until a.empty?
        x = a.shift
        t = (s / n + x) * (n - 1)
        if t >= s
            s = t
            n -= 1
        else
            break
        end
    end
    puts s
end
