Buggy python submission (verdict: Runtime Error):
K = int(input())
A = list(map(int, input().split()))

def winner_count(N, A=A):
    for a in A:
        N = a*(N//a)
    return N

class lazy_eval_list(list):
    def __init__(self, func, a):
        super().__init__(a)
        self._func = func
        
    def __getitem__(self, key):
        return self._func(super().__getitem__(key))

lazy_winner_count_N = lazy_eval_list(winner_count, range(1,2+sum(A)))

import bisect
_min = bisect.bisect_left(lazy_winner_count_N, 2)
_max = bisect.bisect_right(lazy_winner_count_N, 2)-1

if _min > _max:
	print(-1)
else:
	print(_min, _max)

Fixed submission:
K = int(input())
A = list(map(int, input().split()))

def winner_count(N, A=A):
    for a in A:
        N = a*(N//a)
    return N

def bisect_left(func, l, r, target):
    # n>=i ⇒ func(n) <= targetを満たす最小のi
    # l=1, r=sum(A)+2
    # func(l)<= target, target<=func(r)
    if l==r:
        return 0
    if l+1==r:
        if func(l)< target:
            return r
        else:
            return l
    c = (l+r)//2
    if target <= func(c):
        return bisect_left(func, l, c, target)
    else:
        return bisect_left(func, c, r, target)

def bisect_right(func, l,r, target):
    if l==r:
        return 0
    if l+1==r:
        if target < func(r):
            return l
        else:
            return r
    c = (l+r)//2
    if target < func(c):
        return bisect_right(func, l, c, target)
    else:
        return bisect_right(func, c, r, target)

_min = bisect_left(winner_count, 1, sum(A)+2, 2)
_max = bisect_right(winner_count, 1, sum(A)+2, 2)


if _min > _max:
	print(-1)
else:
	print(_min, _max)

Buggy python submission (verdict: Runtime Error):
K = int(input())
A = list(map(int, input().split()))

def winner_count(N, A=A):
    for a in A:
        N = a*(N//a)
    return N

class lazy_eval_list(list):
    def __init__(self, func, a):
        super().__init__(a)
        self._func = func
        
    def __getitem__(self, key):
        return self._func(super().__getitem__(key))

lazy_winner_count_N = lazy_eval_list(winner_count, range(2+sum(A)))

# x = [winner_count(i) for i in range(2+sum(A))]

import bisect
_min = bisect.bisect_left(lazy_winner_count_N, 2)
_max = bisect.bisect_right(lazy_winner_count_N, 2) -1

if _min > _max:
    print(-1)
    exit()

print(_min, _max)

Fixed submission:
K = int(input())
A = list(map(int, input().split()))

def winner_count(N, A=A):
    for a in A:
        N = a*(N//a)
    return N

def bisect_left(func, l, r, target):
    # n>=i ⇒ func(n) <= targetを満たす最小のi
    # l=1, r=sum(A)+2
    # func(l)<= target, target<=func(r)
    if l==r:
        return 0
    if l+1==r:
        if func(l)< target:
            return r
        else:
            return l
    c = (l+r)//2
    if target <= func(c):
        return bisect_left(func, l, c, target)
    else:
        return bisect_left(func, c, r, target)

def bisect_right(func, l,r, target):
    if l==r:
        return 0
    if l+1==r:
        if target < func(r):
            return l
        else:
            return r
    c = (l+r)//2
    if target < func(c):
        return bisect_right(func, l, c, target)
    else:
        return bisect_right(func, c, r, target)

_min = bisect_left(winner_count, 1, sum(A)+2, 2)
_max = bisect_right(winner_count, 1, sum(A)+2, 2)


if _min > _max:
	print(-1)
else:
	print(_min, _max)

Buggy python submission (verdict: Runtime Error):
K = int(input())
A = list(map(int, input().split()))

def winner_count(N, A=A):
    for a in A:
        N = a*(N//a)
    return N

class lazy_eval_list(list):
    def __init__(self, func, a):
        super().__init__(a)
        self._func = func
        
    def __getitem__(self, key):
        return self._func(super().__getitem__(key))

lazy_winner_count_N = lazy_eval_list(winner_count, range(sum(A)))

import bisect
_min = bisect.bisect_left(lazy_winner_count_N, 2)
_max = bisect.bisect_right(lazy_winner_count_N, 2) -1

if _min > _max:
    print(-1)
    exit()

print(_min, _max)

Fixed submission:
K = int(input())
A = list(map(int, input().split()))

def winner_count(N, A=A):
    for a in A:
        N = a*(N//a)
    return N

def bisect_left(func, l, r, target):
    # n>=i ⇒ func(n) <= targetを満たす最小のi
    # l=1, r=sum(A)+2
    # func(l)<= target, target<=func(r)
    if l==r:
        return 0
    if l+1==r:
        if func(l)< target:
            return r
        else:
            return l
    c = (l+r)//2
    if target <= func(c):
        return bisect_left(func, l, c, target)
    else:
        return bisect_left(func, c, r, target)

def bisect_right(func, l,r, target):
    if l==r:
        return 0
    if l+1==r:
        if target < func(r):
            return l
        else:
            return r
    c = (l+r)//2
    if target < func(c):
        return bisect_right(func, l, c, target)
    else:
        return bisect_right(func, c, r, target)

_min = bisect_left(winner_count, 1, sum(A)+2, 2)
_max = bisect_right(winner_count, 1, sum(A)+2, 2)


if _min > _max:
	print(-1)
else:
	print(_min, _max)