Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    now = [2]
    if k == 1:
        print("2 3") if a[0] == 2 else print(-1)
    else:
        for i in reversed(range(1,k)):
            nxt = []
            for j in range(len(now)):
                test = now[j]
                nxtd = a[i-1]
                if test % a[i] == 0:
                    mod = test % nxtd
                    if (nxtd-mod)%nxtd < a[i]:
                        for k in range((nxtd-mod)%nxtd, a[i], nxtd):
                            nxt.append(k+test)
            if not nxt:
                print(-1)
                exit()
            now = nxt
        ans = []
        for i in now:
            test = i
            if test % a[0] == 0:
                ans.append(i)
                ans.append(i+a[0]-1)
        ans = sorted(ans)
        print("{} {}".format(ans[0], ans[-1]))
resolve()

Fixed submission:
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()

Buggy python submission (verdict: Runtime Error):
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    now = [2]
    if k == 1:
        print("2 3") if a[0] == 2 else print(-1)
    else:
        for i in reversed(range(1,k)):
            nxt = []
            for j in range(len(now)):
                test = now[j]
                nxtd = a[i-1]
                if test % a[i] == 0:
                    mod = test % nxtd
                    if (nxtd-mod)%nxtd < a[i]:
                        for k in range((nxtd-mod)%nxtd, a[i], nxtd):
                            nxt.append(k+test)
            if not nxt:
                print(-1)
                exit()
            now = nxt
        ans = []
        for i in now:
            test = i
            if test % a[0] == 0:
                ans.append(i)
                ans.append(i+a[0]-1)
        ans = sorted(ans)
        print("{} {}".format(ans[0], ans[-1]))
resolve()

Fixed submission:
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))

    ra = a[::-1]
    now = [2]
    for i in range(k-1):
        nxt = []
        for j in range(len(now)):
            test = now[j]
            nxtd = ra[i+1]
            if test % ra[i] == 0:
                mod = test % nxtd
                if (nxtd-mod)%nxtd < ra[i]:
                    for k in range((nxtd-mod)%nxtd, ra[i], nxtd):
                        nxt.append(k+test)

        if not nxt:
            print(-1)
            exit()
        now = nxt
    now = sorted(list(now))
    ans = []
    for i in now:
        test = i
        if test % ra[-1] == 0:
            ans.append(i)
            ans.append(i+ra[-1]-1)
    ans = sorted(ans)
    print("{} {}".format(ans[0], ans[-1]))
resolve()

Fixed submission:
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    from collections import deque
    k = int(input())
    a = list(map(int, input().split()))

    ra = a[::-1]
    now = deque([2])
    for i in range(k):
        nxt = deque([])
        while now:
            test = now.popleft()
            if test % ra[i] == 0:
                k = 0
                while k < ra[i]:
                    nxt.append(test+k)
                    k += 1
        if not nxt:
            print(-1)
            exit()
        now = nxt
    nxt = sorted(list(nxt))
    print("{} {}".format(nxt[0], nxt[-1]))
resolve()

Fixed submission:
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    k = int(input())
    a = list(map(int, input().split()))

    ra = a[::-1]
    now = [2]
    for i in range(k):
        nxt = []
        for j in range(len(now)):
            test = now[j]
            if test % ra[i] == 0:
                k = 0
                while k < ra[i]:
                    nxt.append(test+k)
                    k += 1
        if not nxt:
            print(-1)
            exit()
        now = nxt
    nxt = sorted(nxt)
    print("{} {}".format(nxt[0], nxt[-1]))
resolve()

Fixed submission:
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()