Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i-1]
    elif n==2:
    kakekake = kakeru[0] * kakeru[1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = int(input())
b = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        b *= int(a[i])
    b *= a[n]
    if b > 10**18:
       print(-1)
       break
    print(b)    

n = input()
b = 1
a = list(map(str,input().split()))
if "0" in a:
    print(0)
else:
    for i in range(int(a)):
        b *= int(a[i])
    if b > 10**18:
        print(-1)
    else:
        print(b)

n = input()
b = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        b *= int(a[i])
        if b > 10**18:
            print(-1)
            break
    print(b)    

n = input()
kakeru = list(map(int, input().split()))
kakekake = kakeru[0]
    for i in range(n-2):
        kakekake = kakekake * kakeru[i+1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 2:
        for i in range(n-2):
            kakekake = kakekake 
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = map(int,input().split())
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i-1]
    elif n==2:
    kakekake = kakeru[0] * kakeru[1]
if kakekake > 100000000000000000000:
    print(-1)
print(kakekake)

n = input()
b = 1
a = list(map(str,input().split()))
if 0 in a:
    print(0)
else:
    for a in range(int(a)):
        b *= a[0]
    if b > 10**18:
        print(-1)
    else:
        print(b)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 3:
        for i in range(n-3):
            kakekake = kakekake * kakeru[i+1]
    elif n == 2:
        kakekake = kakeru[0] + kakeru[1]
    elif n == 3:
        kakekake = kakeru[0] + kakeru[1] + kakeru[2]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 4:
        for i in range(n-3):
            kakekake = kakekake * kakeru[i+1]
    elif n == 2:
        kakekake = kakeru[0] + kakeru[1]
    elif n == 3:
        kakekake = kakeru[0] + kakeru[1] + kakeru[2]
    elif n == 4:
        kakekake = kakeru[0] + kakeru[1] + kakeru[2] + kakeru[3]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i+1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 1:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i]
if kakekake > 10:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 1:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = map(int, input().split())
kakekake = kakeru[0]
    for i in range(n-2):
        kakekake = kakekake * kakeru[i+1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
b = 1
a = list(map(str,input().split()))
if "0" in a:
    print(0)
else:
    for a in range(int(a)):
        b *= int(a[0])
    if b > 10**18:
        print(-1)
    else:
        print(b)

n = input()
kakeru = map(int,input().split())
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i-1]
    elif n==2:
    kakekake = kakeru[0] * kakeru[1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = int(input())
b = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        b *= int(a[i])
    b *= a[n]
    if b > 10**18:
       print(-1)
    else:print(b)    

n = input()
kakeru = list(map(int, input().split()))
kakekake = kakeru[0]
    for i in range(n-1):
        kakekake = kakekake * kakeru[i+1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i-1]
    elif n==2:
    kakekake = kakeru[0] + kakeru[1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 2:
        for i in range(n-2):
            kakekake = kakekake * kakeru[i+1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = map(int, input().split())
kakekake = kakeru[0]
    if n > 2:
        for i in range(n-2):
            kakekake = kakekake * kakeru[i+1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 1:
        for i in range(n-3):
            kakekake = kakekake * kakeru[i+1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

n = int(input())
b = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        b *= a[i]
        if b > 10**18:
            print(-1)
            break
    if b <=10**18:
        print(b)    


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted