input = readlines()
n = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}




k_list = []
m_total = 1000
remain = list.clone
(1..n).each do |day|
  di = day - 1
  remain.shift() unless di == 0
  if list[di] == remain.max || remain.length == 1
    puts '2'
    m_total += list[di] * k_list.length
    k_list = []
    break
  end
  if list[di] == remain.min
    puts '1'
    k_cnt = m_total / list[di]
    (1..k_cnt).each do |cnt|
      k_list.push(list[di])
    end
    m_total -= list[di] * k_cnt
    next
  end
  if list[di] < remain.min
    puts '3'
    m_total += list[di] * k_list.length
    k_list = []
    next
  end
  k_total = 0
  k_list.each do |kp|
    k_total += kp
  end
  k_avg = k_total / k_list.length.to_f
  if k_avg < list[di]
    puts '4'
    m_total += list[di] * k_list.length
    k_list = []
    next
  end
end

puts m_total
