iii = gets.chomp!.to_i
arr = gets.chomp!.split(" ")
arr2=[]
arr.each do|n|
    arr2 << n.to_i
end
arr = arr2
n = 0
while arr.include?(1) do
    arr2 = []
    arr.each do|s| 
        arr2 << s - 1
    end
    arr = arr2
    n+=1
end
puts n
