#!/usr/bin/env ruby

N = gets.chomp.to_i

A = gets.chomp.split.map(&:to_i)

wanttobuy = true

money = 1000
stock = 0

last = A.size - 1

A.reverse.each_cons(2) do |x, y|
  break if x > y
  last -= 1
end

last += 1
A[last] = 0

A[0..last].each_cons(2) do |x, y|
  warn [x, y].inspect
  case
  when stock <= 0
    next if x >= y

    stock = money / x
    money -= stock * x
    wanttobuy != wanttobuy
  when stock > 0
    next if x <= y

    money += stock * x
    stock = 0
    wanttobuy != wanttobuy
  end

  warn({ money: money, stock: stock, wanttobuy: wanttobuy, x: x, y: y }.inspect)
end

puts money
