def main():
    n = int(input())
    a = [int(v) for v in input().split()]
    m = 1000
    k = 0

    sokosagashi = True
    a0 = a[0]
    ah = a0
    for d,ai in enumerate(a[1:]):
        if ai==a0:
            continue

        if ai>a0:
            if sokosagashi:
                print(d-1, 'sell', k, ah)
                m += k * ah
                k = 0
                sokosagashi = False
            # すべて株に変える
            k = m // a0
            m -= k * a0
            print(d-1, 'buy', k, a0)
            a0 = ai
            ah = ai
        elif ai<a0:
            sokosagashi = True
            a0 = ai
    
    if k>0:
        m += k * ai
    print(m)

main()