
Imports System.Console
Module Module1
    Dim ans As Integer
    Dim money As Int64 = 1000
    Dim kabu As Int64
    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
        'n = n + 1
        'Do While n > 1 AndAlso a(n - 1) >= a(n)
        '    n -= 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)
        ReadLine()
    End Sub
    Sub Buy(ne As Integer)
        kabu += money \ ne
        money = money Mod ne
    End Sub
    Sub Sell(ne As Integer)
        If kabu > 0 Then
            money += kabu * ne
            kabu = 0
        End If
    End Sub
End Module
