n = int(input())
a = list(map(int, input().split()))
money = 1000
kabu = 0
todo = [0]*n
for i in range(n):
    if(i == 0):
        if(a[n-2-i] < a[n-1-i]):
            state = 1
            todo[n-1] = 1#uri
        elif(a[n-2-i] > a[n-1-i]):
            state = -1
            todo[n-1] = 0
        else:
            state = 0
            todo[n-1] = 0
    elif(i == n-1):
        if(state == 1):
            todo[n-1-i] = -1
    else:
        if(a[n-2-i] < a[n-1-i]):
            temp = 1
            if(state != temp):
                todo[n-1-i] = 1
            state = 1
        elif(a[n-2-i] > a[n-1-i]):
            temp = -1
            if(state != temp):
                todo[n-1-i] = -1#kai
            state = -1

for i in range(n):
    if(todo[i] == -1):
        if(money > 0):
            kazu = money//a[i]
            money = money - kazu * a[i]
            kabu = kazu                
    elif(todo[i] == 1):
        money = money + kabu * a[i]
        kabu = 0
    print(money, kabu, todo[i])
    
print(money)