#!/usr/bin/env python

def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = 1000

    lst = []
    flg = 'd'
    for i in range(n-1):
        if flg == 'd' and a[i] < a[i+1]:
            lst.append(a[i])
            flg = 'u'
        elif flg == 'u' and a[i] > a[i+1]:
            lst.append(a[i])
            flg = 'd'

    if flg == 'u':
        lst.append(a[n-1])

    for j in range(0, len(lst), 2):
        p, q = lst[j], lst[j+1]
        m += (q - p) * (m // p)
        print(p, q)

    print(m)

if __name__ == '__main__':
    main()
