Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    # fast return
    if B == 1 or A == 1:
        return 1

    # normal gcd logic
    while B not in (1, 0):
        A, B = min(A, B), abs(A - B)
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)


Fixed submission:
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)

Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    # fast return
    if B == 1 or A == 1:
        return 1

    # normal gcd logic
    if A != B:
        return gcd(min(A, B), abs(A - B))
    else:
        return A

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)


Fixed submission:
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)

Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    if A * B <= 0:
        # at least one is positive
        return max(A, B)
    # fast return
    if B == 1 or A == 1:
        return 1

    # normal gcd logic
    if A != B:
        return gcd(min(A, B), abs(A - B))
    else:
        return A

A.sort()
res = A[0]
for a in A:
    if a <= 0:
        continue
    res = gcd(a, res)
    if res == 1:
        break

print(max(res, 0))


Fixed submission:
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)

Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    if B == 1 or A == 1:
        return 1
    if A > B:
        return gcd(B, A - B)
    elif A < B:
        return gcd(A, B - A)
    else:
        return A

A.sort()
res = A[0]
for a in A:
    res = gcd(a, res)
    if res == 1:
        break
print(res)


Fixed submission:
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)

Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):
    if B == 1 or A == 1:
        return 1
    if A > B:
        return gcd(B, A - B)
    elif A < B:
        return gcd(A, B - A)
    else:
        return A

A.sort()
A.append(None)
res = A[0]
for i, a in enumerate(A):
    if not a:
        break
    res = gcd(a, res)
    if res == 1:
        break
print(res)


Fixed submission:
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list(filter(lambda x:x>0, A))
A.sort()
if len(A) == 0:
    print(0)
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)