line = gets
prices = gets.split(' ').map(&:to_i)

have = 1000
kabu_num = 0

prices.each_with_index do |price,i|
  if prices[i+1].nil?
    if price < prices[i-1]
      kabu_num = have / price
      r = have - kabu_num * price
      have = r if have < r
    end
    if price > prices[i-1]
      r = have + kabu_num * price
      have = r if have < r
    end
    break
  end
  if price < prices[i+1]
    kabu_num = have / price
    have = have - kabu_num * price
  end
  if price > prices[i+1]
    have = have + kabu_num * price
  end
end

puts have