N = int(input())
A = list(map(int, input().split()))
A_max = max(A)

is_start_increase = [0]*N
is_end_increase = [0]*N
is_increasing = [0]*N

# for i in range(1, N):
#     if A[i-1] <= A[i]:
#         is_increasing[i] = 1
# next_is_end = 0
# is_total_start = 0
# for i in range(0, N-1):
#     if next_is_end:
#         if is_increasing[i] == 1 and is_increasing[i+1] == 0:
#             is_end_increase[i] = 1
#             next_is_end = 0

#     if not is_total_start:
#         if is_increasing[i+1] == 1:
#             is_start_increase[i] = 1
#             is_total_start = 1
#             next_is_end = 1
#     # if i == 0 and is_increasing[i+1] == 1:
#     #     is_start_increase[i] = 1
#     #     continue
#     # if i == 1 and is_start_increase[i-1]==1:
#     #     continue
#     elif next_is_end == 0:
#         if is_increasing[i] == 1 and is_increasing[i-1] == 0:
#             is_start_increase[i] = 1
#             next_is_end = 1

for i in range(N-1):
    if A[i] <= A[i+1]:
        is_increasing[i] = 1
if is_increasing[0] == 1:
    is_start_increase[0] = 1
for i in range(1, N-1):
    if is_increasing[i] == 1 and is_increasing[i-1] == 0:
        is_start_increase[i] = 1
    if is_increasing[i] == 0 and is_increasing[i-1] == 1:
        is_end_increase[i] = 1

money = 1000
stock = 0
stocks = []
for i in range(N):
    if i==N-1:
        print("last", i)
        money += stock * A[i]
        break
    if is_start_increase[i]:
        print("start", i)
        stock += money // A[i]
        money -= A[i] * stock
    if is_end_increase[i]:
        print("end", i)
        money += stock * A[i]
        stock = 0
    stocks.append(stock)

print(money, stock)
print(stocks)