N = int(input())
A = [int(x) for x in input().split()]
money = 1000
sell = 0
num = 0
for i in range(N-1):
    if A[i] < A[i+1]:
        print("buy")
        num += int(money / A[i])
        money %= A[i]
        print(num,money)
        sell = 1
    elif sell == 1:
        money += num * A[i]
        num = 0
        sell = 0
        print(num,money)
if num > 0:
    money += num*A[N-1]
print(money)
