n = gets.to_i
a = gets.split.map(&:to_i)

pair = Struct.new("Pair", :c, :s)
dp = Array.new(n+1).map{Array.new(3)}

dp[0][0] = pair.new(1000, 0) # none
dp[0][1] = pair.new(1000, 0) # buy 
dp[0][2] = pair.new(1000, 0) # sale

for i in 1..n
    v = a[i-1]

    vv = Array.new(3)
    vmax = -1
    vmaxj = 0
    cmax = -1
    cmaxj = 0
    for j in 0...3
        dp[i][j] = 
        vv[j] = dp[i-1][j].s * v + dp[i-1][j].c
        if vv[j] > vmax || (vv[j] == vmax && dp[i-1][j].s > dp[i-1][vmaxj].s)
            vmaxj = j
            vmax = vv[j]
        end
        if dp[i-1][j].c > cmax
            cmaxj = j
            cmax = dp[i-1][j].c
        end
    end

    dp[i][0] = pair.new(dp[i-1][vmaxj].c, dp[i-1][vmaxj].s)

    dp[i][1] = pair.new(vv[vmaxj], 0)

    m = cmax / v
    dp[i][2] = pair.new(dp[i-1][cmaxj].c - m * v, dp[i-1][cmaxj].s + m)
end

ans = -1
for j in 0...3
    vv = dp[n][j].s * v + dp[n][j].c
    if vv > ans
        ans = vv
    end
end

puts ans
