import Foundation

func solve(_ arr: [Int], _ m: Int) -> Int {
    var dp = [[Int]](repeating:[Int](repeating: 0, count: 3), count: arr.count) //stock, remainder, money
    dp[0] = [m/arr[0], m%arr[0], m]
    for i in stride(from: 1, to: arr.count, by: 1) {
        let ifBoughtStockPreviousDay = arr[i] * dp[i-1][0] + dp[i-1][1]
        let moneyTillPreviousDay = dp[i-1][2]
        if ifBoughtStockPreviousDay >= moneyTillPreviousDay {
            dp[i] = [dp[i-1][0], dp[i-1][1], arr[i] * dp[i-1][0] + dp[i-1][1]]
        } else {
            let m = dp[i-1][2]
            dp[i] = [m/arr[i], m%arr[i], m]
        }
    }
    return dp.last![2]
}


let n = Int(readLine()!)!
let arr = readLine()!.split(separator: " ").map { Int($0)! }

print(solve(arr, 1000))
