Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
st = input()

N = n.split(' ')[0]
Q = int(n.split(' ')[1])

for i in range(0, Q):
    n = input()
    l = int(n.split(' ')[0])
    r = int(n.split(' ')[1])
    partial = st[l-1:r]
    count = 0
    for i in range(0, len(partial) - 1):
        if partial[i] != 'A':
            continue

        AC = partial[i:i+2]
        if AC == 'AC':
            count += 1

    print(count)

Fixed submission:
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for i in range(q)]

cum=[0]*n
for i in range(1, n):
    cum[i] = cum[i - 1]
    if s[i-1:i+1] == 'AC':
        cum[i]+=1

for i in range(q):
    print(cum[a[i][1]-1]-cum[a[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
st = input()

N = n.split(' ')[0]
Q = int(n.split(' ')[1])

for i in range(0, Q):
    n = input()
    l = int(n.split(' ')[0])
    r = int(n.split(' ')[1])
    partial = st[l-1:r]
    count = 0
    for i in range(0, len(partial) - 1):
        if partial[i] != 'A':
            continue

        AC = partial[i:i+2]
        if AC == 'AC':
            count += 1

    print(count)

Fixed submission:
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for i in range(q)]

cum=[0]*n
for i in range(1, n):
    cum[i] = cum[i - 1]
    if s[i-1:i+1] == 'AC':
        cum[i]+=1

for i in range(q):
    print(cum[a[i][1]-1]-cum[a[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
st = input()

N = n.split(' ')[0]
Q = int(n.split(' ')[1])

for i in range(0, Q):
    n = input()
    l = int(n.split(' ')[0])
    r = int(n.split(' ')[1])
    partial = st[l-1:r]
    count = 0
    for i in range(0, len(partial) - 1):
        AC = partial[i:i+2]
        if AC == 'AC':
            count += 1

    print(count)

Fixed submission:
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for i in range(q)]

cum=[0]*n
for i in range(1, n):
    cum[i] = cum[i - 1]
    if s[i-1:i+1] == 'AC':
        cum[i]+=1

for i in range(q):
    print(cum[a[i][1]-1]-cum[a[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
st = input()

N = n.split(' ')[0]
Q = int(n.split(' ')[1])

for i in range(0, Q):
    n = input()
    l = int(n.split(' ')[0])
    r = int(n.split(' ')[1])
    partial = st[l-1:r]
    count = 0
    while partial.find('AC') != -1:
        partial = partial.replace('AC', '', 1)
        count += 1
    print(count)

Fixed submission:
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for i in range(q)]

cum=[0]*n
for i in range(1, n):
    cum[i] = cum[i - 1]
    if s[i-1:i+1] == 'AC':
        cum[i]+=1

for i in range(q):
    print(cum[a[i][1]-1]-cum[a[i][0]-1])
Buggy python submission (verdict: Runtime Error):
import fractions

# N個の最大公約数
# ユークリッド互除法


def good(A):
    ans = A[0]
    for i in range(1, N):
        ans = fractions.gcd(A[1], ans)
    print(ans)


def my(A):
    A = sorted(A)

    while True:
        v = A[0]
        tmp = [v]
        for i in range(len(A)):
            if A[i] % v == 1:
                print(1)
                return
            if A[i] % v == 0:
                pass
            else:
                tmp.append(A[i] % v)

        if len(A) == 1:
            print(A[0])
            return

        A = sorted(tmp)
        # print(A)


def main():
    N = int(input())
    A = list(map(int, input().split()))

    good(A)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)

    while True:
        v = A[0]
        tmp = [v]
        for i in range(len(A)):
            if A[i] % v == 1:
                print(1)
                return
            if A[i] % v == 0:
                pass
            else:
                tmp.append(A[i] % v)

        if len(A) == 1:
            print(A[0])
            return

        A = sorted(tmp)
        # print(A)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
IINF = 10 ** 18


def main():
    N, M = list(map(int, input().split()))
    X = list(map(int, input().split()))
    X = sorted(X)
    left = -IINF
    right = IINF

    for i in range(N):
        if len(X) == 0:
            break
        elif i == 0:
            left = X[0]
            X.pop(0)
        elif i == 1:
            right = X[-1]
            X.pop(len(X)-1)
        else:
            if abs(X[1] - X[-1]) < abs(X[-2] - X[0]):
                left = X[0]
                X.pop(0)
            else:
                right = X[-1]
                X.pop(-1)

    ans = 0
    while len(X) > 0:
        # print(ans, X)
        if abs(left - X[0]) < abs(right - X[-1]):
            ans += abs(left - X[0])
            left = X[0]
            X.pop(0)
        else:
            ans += abs(right - X[-1])
            right = X[-1]
            X.pop(len(X)-1)
        # b = min(abs(left - X[0]), abs(right - X[-1]))
        # print(b, X)
        # print(abs(X[0] - X[-1]) + b)
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
IINF = 10 ** 18


def main():
    N, M = list(map(int, input().split()))
    X = list(map(int, input().split()))
    X = sorted(X)
    # left = -IINF
    # right = IINF

    # print(M, N)
    if M <= N:
        print(0)
        return
    else:
        L = []
        for i in range(M-1):
            L.append(X[i+1]-X[i])

        # print(L)

        L.sort()
        if N == 1:
            ans = sum(L)
            print(ans)
        else:
            ans = sum(L[0:-(N-1)])
            print(ans)

    # for i in range(N):
    #     if len(X) == 0:
    #         break
    #     elif i == 0:
    #         left = X[0]
    #         X.pop(0)
    #     elif i == 1:
    #         right = X[-1]
    #         X.pop(len(X)-1)
    #     else:
    #         if abs(X[1] - X[-1]) < abs(X[-2] - X[0]):
    #             left = X[0]
    #             X.pop(0)
    #         else:
    #             right = X[-1]
    #             X.pop(-1)

    # ans = 0
    # while len(X) > 0:
    #     # print(ans, X)
    #     if abs(left - X[0]) < abs(right - X[-1]):
    #         ans += abs(left - X[0])
    #         left = X[0]
    #         X.pop(0)
    #     else:
    #         ans += abs(right - X[-1])
    #         right = X[-1]
    #         X.pop(len(X)-1)
    #     # b = min(abs(left - X[0]), abs(right - X[-1]))
    #     # print(b, X)
    #     # print(abs(X[0] - X[-1]) + b)
    # print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
ans = 0

for i in range(N):
  for j in range(i+1, N):
    ans = max(ans, abs(A[i] - A[j]))

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
 
for i in range(N):
  for j in range(i+1, N):
    ans = max(ans, abs(A[i] - A[j]))
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
SN = sum([int(i) for i in N])

if N % SN == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
N = input()
SN = sum([int(i) for i in N])
 
if int(N) % SN == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
X = int(input())
A = int(input())
B = int(input())

X -= A
print(x % B)

Fixed submission:
X = int(input())
A = int(input())
B = int(input())
 
X -= A
print(X % B)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
N = int(input())

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a * 500 + b * 100 + c * 50 == N:
        ans += 1

print(ans)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
N = int(input())
ans = 0
 
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a * 500 + b * 100 + c * 50 == N:
        ans += 1
 
print(ans)
Buggy python submission (verdict: Runtime Error):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    X, Y = MI()
    tmp = int(math.log2(Y/X))
    print(tmp + 1)


if __name__ == '__main__':
    main()


Fixed submission:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    X, Y = MI()
    # tmp = math.log2(Y) - math.log2(X)
    # print(int(tmp) + 1)

    ans = 0
    c = X
    while c <= Y:
        c = c * 2
        ans += 1

    print(ans)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    S = input()
    center = len(S) // 2

    if len(S) % 2 == 0:
        c = 1
        while True:
            if S[center - c] == S[center + c] and S[center - c] == S[center - 1]:
                c += 1
            else:
                break
        print(c + center - 1)
    else:
        c = 1
        while True:
            if S[center - c] == S[center + c] and S[center] == S[center - c]:
                c += 1
            else:
                break
        print(c + center)


if __name__ == '__main__':
    main()


Fixed submission:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    S = input()
    center = len(S) // 2

    if len(S) % 2 == 0:
        c = 1
        while True:
            if (center - 1 + c) < len(S) and S[center - c] == S[center - 1 + c] and S[center - c] == S[center]:
                # if S[center - c] == S[center]:
                # print(c, center - c, center - 1 + c, S[center - c], S[center])
                c += 1
            else:
                # print(c, S[center - c], S[center - 1 + c])
                # c -= 1
                break
        print(c + center - 1)
    else:
        c = 0
        while True:
            if (center + c) < len(S) and S[center - c] == S[center + c] and S[center] == S[center - c]:
                c += 1
            else:
                break
        print(c + center)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s = input()
print(len([i for i in s i == '1']))

Fixed submission:
s = input()
print(len([i for i in s if i == '1']))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [0] * N
L[0] = 2
L[1] = 1

for i in range(2, N):
  L[i] = L[i-1] + L[i-2]

print(L[N-1])

Fixed submission:
N = int(input())
L = [0] * (N + 1)
L[0] = 2
L[1] = 1
 
for i in range(2, N+1):
  L[i] = L[i-1] + L[i-2]
 
print(L[N])
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def base_10_to_n(X, n):
    if int(X / n):
        return base_10_to_n(int(X/n), n) + str(X % n)
    return str(X % n)


def main():
    A = I()

    for i in range(10, 10000+1):
        print(i, base_10_to_n(A, i))
        if str(i) == base_10_to_n(A, i):
            print(i)
            return

    print(-1)


if __name__ == '__main__':
    main()


Fixed submission:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()
    d = deque(s)
    ans = 0

    # print(d)

    while len(d) > 1:
        if d[0] == d[-1]:
            d.popleft()
            d.pop()
        elif d[0] == 'x':
            d.append('x')
            ans += 1
        elif d[-1] == 'x':
            d.appendleft('x')
            ans += 1
        else:
            print(-1)
            return

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())

print(max(a) - min(a))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))

print(max(a) - min(a))
Buggy python submission (verdict: Runtime Error):
N = input()
dic = defaultdict(int)

for s in N:
  dic[s] += 1
  
  if dic[s] > 1:
    print('no')
    exit()

print('yes')

Fixed submission:
from collections import defaultdict 

N = input()
dic = defaultdict(int)
 
for s in N:
  dic[s] += 1
  
  if dic[s] > 1:
    print('no')
    exit()
 
print('yes')
Buggy python submission (verdict: Runtime Error):
A, B = input(int, input().split())

print((A + B) % 24)

Fixed submission:
A, B = map(int, input().split())
 
print((A + B) % 24)
Buggy python submission (verdict: Runtime Error):
a, b = map(str, input().split())
m = {'D': 'H', 'H': 'D'}

if a == 'H':
  print(b)
else a == 'D':
  print(m[b])

Fixed submission:
a, b = map(str, input().split())
m = {'D': 'H', 'H': 'D'}
 
if a == 'H':
  print(b)
else:
  print(m[b])
Buggy python submission (verdict: Runtime Error):
s = input()
ans = []

for i in range(len(s)):
  if len(s) < 2 and (s[i] == 'C' or s[i] == 'F'):
    ans.append(s)

if ans[0] == 'C' and ans[1] == 'F':
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()
ans = []

for i in range(len(s)):
  if len(ans) == 0 and s[i] == 'C':
    ans.append(s[i])
  elif len(ans) == 1 and s[i] == 'F':
    ans.append(s[i])

if len(ans) == 2 and ans[0] == 'C' and ans[1] == 'F':
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
L = sort(list(map(int, input().split())))
 
if L[0] == 5 and L[1] == 5 and L[2] == 7:
  print('YES')
else:
  print('NO')

Fixed submission:
L = sorted(list(map(int, input().split())))
 
if L[0] == 5 and L[1] == 5 and L[2] == 7:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
item = input()
if 7 in item:
  print("Yes")
else:
  print("No")

Fixed submission:
item = input()
if "7" in item:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

A, B = map(int, input().split())
if A + B >= 10: print("error")
else print(A+B)

Fixed submission:
# -*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

A, B = map(int, input().split())
if A + B >= 10: print("error")
else: print(A+B)
Buggy python submission (verdict: Runtime Error):
-*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

s = input()
print(1)




Fixed submission:
s = input()
     
a = s.find("A")
b = s.rfind("Z")
     
print(b-a+1)

Buggy python submission (verdict: Runtime Error):
-*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

s = input()
print(s.rfind("Z") - s.find("A") + 1)




Fixed submission:
s = input()
     
a = s.find("A")
b = s.rfind("Z")
     
print(b-a+1)

Buggy python submission (verdict: Runtime Error):


     -*- coding: utf-8 -*-
     
    import sys
    import subprocess
    import json
    import time
    import math
    import re
    import sqlite3
     
    s = input()
    print(s.rfind("Z") - s.find("A") + 1)

Fixed submission:
s = input()
     
a = s.find("A")
b = s.rfind("Z")
     
print(b-a+1)

Buggy python submission (verdict: Runtime Error):
 -*- coding: utf-8 -*-

s = input()
print(s.rfind('Z') - s.find('A') + 1)

Fixed submission:
s = input()
     
a = s.find("A")
b = s.rfind("Z")
     
print(b-a+1)

Buggy python submission (verdict: Runtime Error):
 -*- coding: utf-8 -*-
 
import sys
import subprocess
import json
import time
import math
import re
import sqlite3
 
s = input()
print(s.rfind('Z') - s.find('A') + 1)

Fixed submission:
s = input()
     
a = s.find("A")
b = s.rfind("Z")
     
print(b-a+1)
Buggy python submission (verdict: Runtime Error):
s=[]
a=int(input())

if a==0:
    s.append(0)
elif a==1:
    s.append(1)
else:
    if len(s)>0:
        s.pop()
        
for l in s:
    print(l)

Fixed submission:
s=[]
a=list(input())

for i in a:
    if i=='0':
        s.append('0')
    elif i=='1':
        s.append('1')
    else:
        if len(s)==0:
            pass
        else:
            s.pop()

b="".join(s)
print(b)
Buggy python submission (verdict: Runtime Error):
S=list(input())
T=list(input())
A=[]
for i in range(len(S)-len(T)):
    B=0
    for j in range(len(T)):
        if T[j]==S[i+j]:
            continue
        else:
            B =B+1
    A.append(B)

A.sort()
print(A[0])

Fixed submission:
S=list(input())
T=list(input())
A=[]
for i in range(len(S)-len(T)+1):
    B=0
    for j in range(len(T)):
        if T[j]==S[i+j]:
            continue
        else:
            B =B+1
    A.append(B)

A.sort()
print(A[0])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
B = 0
while N>0:
    A.append(N%10)
    N //=10
for i in range(len(A)):
    B = B+A[i]
if B%9 == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N = list(input())
A = 0

for i in range(len(N)):
    B = int(N[i])
    A += B
if A%9 == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
M=1
for i in range(len(A)):
    M*=A[i]
if M <= 10**18:
    print(int(M))
else:
    print('-1')

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
M=1
if 0 in A:
    print('0')
else:
    for i in range(len(A)):
        M*=A[i]
        if M > 10**18:
            break
    if M > 10**18:
        print('-1')
    else:
        print(int(M))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
M=1
for i in range(N):
    M*=A[i]
if M <= 10**18:
    print(int(M))
else:
    print('-1')

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
M=1
if 0 in A:
    print('0')
else:
    for i in range(len(A)):
        M*=A[i]
        if M > 10**18:
            break
    if M > 10**18:
        print('-1')
    else:
        print(int(M))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
M=1
for i in range(N):
    M*=A[i]
if M <= 10**18:
    print(int(M))
else:
    print('-1')

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
M=1
if 0 in A:
    print('0')
else:
    for i in range(len(A)):
        M*=A[i]
        if M > 10**18:
            break
    if M > 10**18:
        print('-1')
    else:
        print(int(M))