
Imports System.Console
Module Module1
    Dim ans As Integer
    Dim money As Integer = 1000
    Dim kabu As Integer
    Sub Main()
        Dim n As Integer = ReadLine()
        Dim s() As String = ReadLine().Split
        Dim a(n + 1) As Integer
        For i = 1 To n
            a(i) = s(i - 1)
        Next
        a(0) = 0
        Dim w As Integer
        Dim realn As Integer = n
        Do While w = realn OrElse a(realn - w) < a(realn - w - 1)
            n -= 1
            w += 1
        Loop
        For i = 1 To n
            If a(i + 1) > a(i) Then
                Buy(a(i))
            Else
                Sell(a(i))
            End If
        Next
        WriteLine(money)
    End Sub
    Sub Buy(ByVal ne As Integer)
        kabu = money \ ne
        money = money Mod ne
    End Sub
    Sub Sell(ByVal ne As Integer)
        money += kabu * ne
        kabu = 0
    End Sub
End Module
