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()

ab = input( )

ab = ab.split()

SUM = 1
for i in range(len(ab)):
    SUM = SUM * int(ab[i])
    
if (int(SUM) < 10 ** 18):
    print(SUM)
else:
    print(-1)

N = input()

ab = input( )

ab = ab.split()


SUM = 1
for i in range(int(N)):
    SUM = SUM * int(ab[i])

if int(SUM) < 10 ** 18:
    print(SUM)
else:
    print(-1)

N = input()

ab = input( )

ab = ab.split()

SUM = 1
for i in range(int(N)):
    SUM = SUM * int(ab[i])
    
if (int(SUM) < 10 ** 18):
    print(SUM)
else:
    print(-1)

N = input()

A = []

for i in range(1,int(N)+1):
    a = input()
    A.append(a)

SUM = 1
for i in range(len(A)):
    SUM = SUM * int(A[i])
    
if (int(SUM) < 10 ** 18):
    print(SUM)
else:
    print(-1)

N = input()

ab = input( )

ab = ab.split()

SUM = 1
for i in range(int(N)):
    SUM = SUM * int(ab[i])
    
if (int(SUM) < 10 ** 18):
    print(SUM)
else:
    print(-1)

N = input()

    ab = input( )

    ab = ab.split()
    
    if 0 in ab:
        print(0)


    SUM = 1
    for i in range(int(N)):
        SUM = SUM * int(ab[i])
        if (int(SUM) < 10 ** 18):
            print(SUM)
        else:
        print(-1)

ab = input( )

ab = ab.split()

SUM = 1
for i in range(int(ab[0])):
    SUM = SUM * int(ab[i+1])
    
if (int(SUM) < 10 ** 18):
    print(SUM)
else:
    print(-1)

def main():
    N = input()

    ab = input( )

    ab = ab.split()
    
    if 0 in ab:
        print(0)


    SUM = 1
    for i in range(int(N)):
        SUM = SUM * int(ab[i])
         if (int(SUM) < 10 ** 18):
        	print(SUM)
        else:
        print(-1)
        
main()

def main():
    N = input()

    ab = input( )

    ab = ab.split()
    
    if 0 in ab:
        print(0)


    SUM = 1
    for i in range(int(N)):
        SUM = SUM * int(ab[i])
         if (int(SUM) < 10 ** 18):
        print(SUM)
        else:
        print(-1)
        
main()

def main():
    N = input()

    ab = input( )

    ab = ab.split()
    
    if 0 in ab:
        print(0)


    SUM = 1
    for i in range(int(N)):
        SUM = SUM * int(ab[i])
        if (int(SUM) < 10 ** 18):
            print(SUM)
        else:
            print(-1)
        
main()

def main ():
N = int(input())
A = list(map(int,input().split()))
if 0 in A: print (0)
return
prod = 1 for a in A:
prod *= a
if prod > 1000000000000000000:
print(-1) return
print(prod) main ()

def main():
    N = input()

    ab = input( )

    ab = ab.split()


    SUM = 1
    for i in range(int(N)):
        SUM = SUM * int(ab[i])

    if (int(SUM) < 10 ** 18):
        print(SUM)
    else:
        print(-1)
        
main()

N = input()

ab = input( )

ab = ab.split()


SUM = 1
for i in range(int(N)):
    SUM = SUM * int(ab[i])

if (int(SUM) < 10 ** 18):
    print(SUM)
else:
    print(-1)

def main():
    N = input()

    ab = input( )

    ab = ab.split()
    
    if 0 in ab:
        print(0)


    SUM = 1
    for i in range(int(N)):
        SUM = SUM * int(ab[i])

    if (int(SUM) < 10 ** 18):
        print(SUM)
    else:
        print(-1)
        
main()

def main ():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
        print (0)
        return
    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1) 
            return
    print(prod)

    
main ()

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted