n = gets.to_i
a = gets.split(" ").map(&:to_i).slice(0,n)

BUY ="buy"
SELL="sell"
NO  = ""

chart =[]
last =0
a.each_index{|d|
    action = NO
    if d == 0
        action = BUY
    else
        if a[d] > a[d-1]
            action=SELL
            chart[d-1]=NO if chart[d-1] == SELL
        elsif a[d] < a[d-1]
            action = BUY
            chart[d-1]=NO if chart[d-1]=BUY
        end
    end
    chart.push(action)
}

money = 1000
stock=0
chart.each_index { |d|
    action = chart[d]
    price  = a[d]
    case action
    when BUY then
        count = money / price
        money = money - count * price
        stock += count
    when SELL then
        money += stock * price
        stock = 0
    end
}

puts  money < 1000 ? 1000 : money
