Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil, factorial, log,tan,pi,cos,sin,radians
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
from fractions import Fraction
from functools import reduce
from decimal import *
import string
import sys
import os
import re
inf = float('inf')
mod_ = int(1e9) + 7
mod = 998244353

def factors(n):
    from functools import reduce
    return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def sieve(m):
    n=1
    primes = {}
    arr=set([])
    for i in range(2, int(m ** 0.5) + 1):
        a = n // i
        b = m // i
        for k in range(max(2, a), b + 1):
            c = i * k
            primes[c] = 1

    for i in range(max(n, 2), m + 1):
        if i not in primes:
            arr.add(i)

    return arr


class DisjointSetUnion:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n
 
    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a
 
    def union(self, a, b):
        a, b = self.find(a), self.find(b)
        if a != b:
            if self.size[a] < self.size[b]:
                a, b = b, a
 
            self.num_sets -= 1
            self.parent[b] = a
            self.size[a] += self.size[b]
 
    def set_size(self, a):
        return self.size[self.find(a)]
 
    def __len__(self):
        return self.num_sets



def main():
    n=int(input())
    prod=1
    arr=list(map(int,input().split()))
    for i in arr:
        prod*=i
        if i>10**18:
            print(-1)
            exit()
    print(prod)
    # n,m=
    # print(n*m)












    



# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
for ni in A:
  if ni == 0:
    print(0)
    exit()
  ans *= ni
  if ans > 1000000000000000000:
    print(-1)
    exit()
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
k=1
for i in range(n):
    k*=a[i]
    if k>10**18:
        print(-1)
        exit()
print(k)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))

a=1
for i in range(N):
  a *= A[i]
  if a>10**18:
    a=-1
    break
print(a)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    array = [int(x) for x in input().split()]
    mod = 10 ** 18
    ans = 1
    for x in array:
        ans *= x
        if ans > mod:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    answer = 1
    for aa in a:
        answer *= aa
        if answer > 10 ** 18:
            print(-1)
            break
    else:
        print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
          print(-1)
          exit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

ans = 1
j = 0
for a in A:
  ans = ans*a
  if(ans > 10**18):
    j = 1
    break
    
if(j == 0):
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

n = INT()
a = LIST()
ans = a[0]

for x in a[1:]:
    ans *= x
    if ans > 10 ** 18:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
var = pow(10,18)
for i in range(len(A)):
    ans *= A[i]
    if ans > var:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

#n = int(input())
#a,b = map(int,input().split())
a_L = list(map(int,input().split()))
ans = 1
for i in a_L:
    ans = ans*i
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = 1
for i in range(N):
    B = B*A[i]
print(B)

Submission status: Wrong Answer

Solution code:
import sys


def main():
  readline = sys.stdin.readline
  
  n = int(readline().rstrip())
  a = [int(a_i) for a_i in readline().rstrip().split()]
  
  pr = 1
  for a_i in a:
    pr *= a_i
    
    if pr > 10 ** 18:
      print(-1)
      return
    
  print(pr)
  
  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = 1
for k in a:
  s *= k
  if s > 10**18:
    print(-1)
    exit()
print(s)

Submission status: Wrong Answer

Solution code:

def main():
  _n = int(input())
  ans = 1
  for num in map(int, input().split()):
    ans *= num
    if ans > 10**18:
      print(-1)
      return

  print(ans)

main()

Submission status: Wrong Answer

Solution code:
n = int(input())

res = 1
aborted = False
thresh = 10 ** 18
for a in [int(v) for v in input().split()]:
    res *= a
    if res > thresh:
        aborted = True
        break

if aborted:
    print(-1)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
total = 1
count = 0
for i in range(n):
    total *= A[i]
    if total > 10**18:
        count += 1
        break
if count == 1:
    print('-1')
else:
    print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
LIM = 10 ** 18
ans = 1
for i in A:
    ans *= i
    if ans > LIM:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = list(map(int,input().split()))
num = 1
for i in range(n):
    num *=L[i]
    if num > 10**18:
        print(-1)
        exit()
print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(map(int,input().split()))
answer = 1.
for a in A_list:
    answer*=a

if answer > 10**18:
    print(-1)
else:
    print(answer)

Submission status: Wrong Answer

Solution code:
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor, gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    N = II()
    A = LMIIS()
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
now = 1
for one in a:
    now *= one
    if now >= 1e18:
        print("-1")
        exit()
print(now)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
t = 1
for num in a:
  t *= num
  if t > 10**18:
    break
if t <= 10**18:
  print(t)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
l = 1000000000000000000
for i in range(n):
  ans *= a[i]
  if ans > l:
    ans = -1
    break
print(ans)

Submission status: Wrong Answer

Solution code:

n = int(input())
a_list = [int(i) for i in input().split()]

ans = 1
for i in a_list:
  ans *= i
  if ans > 10**18:
    ans = -1
    break
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = [int(_c) for _c in input().split(" ")]

res = 1
for a in a_list:
    res = res * a

if res > 10 ^ 18:
    print(-1)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
cnt=1
for i in range(N):
    cnt*=A[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
m = 1
for a in A:
  m *= a
  if m>10**18:
    print(-1)
    break
else:
  print(m)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    limit = 10**18
    ans = 1
    for i in A:
        if A == 0:
            print(0)
            return
        if ans > limit:
            print(-1)
            return
        ans *= i
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
tmp = 1
pin= 0
for i in range(N):
    tmp = tmp * A[i]
    if tmp > 10 ** 18:
        pin = 1
        print(-1)
if pin == 0:
    print(tmp)

Submission status: Wrong Answer

Solution code:
input()
p=1
flag=True
for i in input().split():
  p*=int(i)
  if p>10**18:
    flag=False
    print(-1)
    break
if flag:
  print(p)

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[int(i) for i in input().split()]
f=1 
prod=1 
for i in arr:
    prod*=i 
    if prod>10**18:
        f=0 
print(prod if f else -1)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
ans=1

for a in A:
  ans *= a
  if ans > 10**18:
    print('-1')
    exit()
    
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
ans = 1
for aa in a:
    ans *= aa
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
n = ni()
A = list(ma())
ans = 1
for a in A:
    ans*=a
    if ans>=10**18:
        ans = -1
        break
mi = min(A)
if mi>0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int, input().split(" ")))
ans = 1
for i in v:
    ans *= i
    if ans > int(1e18):
        print(-1)
        break

if ans <= int(1e18):
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
answer = 1
for i in range(N):
  answer *= int(A[i])
  
if (answer // (10**18)) >= 1:
  print(-1)
else:
  print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 1

for a in A:
  ans*=a

if ans>=10**18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(n) for n in input().split()]

ans = 1
LIMIT = 1000000000 ** 2
for a in A:
    ans *= a
    if ans > LIMIT:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
inf = 10 ** 18
if 0 in a:
    print(0)
    exit()
for x in a:
    ans *= x
    if ans >= inf:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

an = 1

for x in a:
  an *= x
  if (an > 10**18):
    print(-1)
    exit(0)

print(an)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
def __main__():
    ans = 1
    for i in a:
        ans *= i
        if(ans > 10**18):
            print(-1)
            return
    print(ans)
    return

if(__name__=="__main__"):
    __main__()

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline

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

ans = 1

for a in A:
    ans *= a
    if a > pow(10, 18) or ans > pow(10, 18):
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
total = 1
maxi = 10 ** 18
for ae in a:
    total *= ae
    if total > maxi:
        print(-1)
        exit()
print(total)

Submission status: Wrong Answer

Solution code:
N=int(input())
A= list(map(int, input().split()))
sum = 1
for i in range(N):
    sum *= A[i]
    if sum > 1000000000000000000:
        print(-1)
        exit()
print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
INF = 10 ** 18
ans = 1
for num in arr:
    ans *= num
    if ans > INF:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
c=1
flag=True
for i in range(N):
    c*=a[i]
    if c>10**18:
        flag=False
        break
if flag:
    print(c)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split())) 
lim = 10**18
ans = 1
for i in A:
    ans *= i
    if ans> lim:
        print("-1")
        quit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
  if ans * A[i] > 1000000000000000000:
    ans = -1
    break
  ans *= A[i]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))

ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
As = list(map(int,input().split()))

sum = np.prod(np.asarray(As))
sum = sum if sum<=10**18 else -1
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 1
for a in A:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        sys.exit(0)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(i) for i in input().split()]
prod=1
for i in range(0,n):
  prod=prod*A[i]
  if(prod>1000000000000000000):
    prod=-1
    break
print(prod)

Submission status: Wrong Answer

Solution code:

n = int(input())

a = list(map(int,input().split()))

ans = 1
for i in range(n):
    if ans >= 10 ** 18:
        print(-1)
        exit()
    ans = ans * a[i]

print(ans)

Submission status: Wrong Answer

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))
 
def main():
    n=I()
    a=L()
    ans=1
    for i in a:
        ans*=i
    print(ans if ans<1e+18 else -1)
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
b=A[0]

for i in range(1,len(A)):
    b=b*A[i]
    if(10**18<=b):
        print('-1')
        exit()

print(b)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(n):
    ans*=A[i]
    if ans>10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = inp()
    a = inpl()
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            print(-1)
            return
        if ans == 0:
            print(0)
            return
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1
    for jj in j:
        res *= jj
        if 1e18 <= res:
            print(-1)
            return 0

    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    num = 1000000000000000000
    ans = 0
    for i in range(n):
        ans *= a_list[i]

    if ans < num:
        print(ans)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

ans = 1
for a in A:
    ans *= a
    if ans>10**18:
        print(-1)
        exit()

if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l = list(map(int,input().split()))
s=1
for i in l:
    s*=i
    if s>10**18:
        s=-1
        break
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = A[0]
for i in range(1, N):
    ans *= A[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    over = 10 ** 18
    for i in range(N):
        ans = ans * A[i]
        if ans > over:
            print('-1')
            exit()

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
input()
s = sum(map(int,input().split()))
print(s if s<=10e+18 else -1)

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
m = nl()
res = 1
for i in m:
    res *= i
    if res > 10**18 :
        print(-1)
        break
else:
    print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
if 0 in A:
    print(0)
    exit(0)
mul = 1
for a in A:
    if mul * a > 10 ** 18:
        print(-1)
        exit(0)
    mul *= a
print(mul)

Submission status: Wrong Answer

Solution code:
from math import sqrt,gcd,ceil 
def ii():return int(input())
def mi():return map(int,input().split())
def li():return list(mi())
def si():return input()

n=ii()
a=li()
s=1
for i in a:
    s*=i
    if(s>1e18):
        break
if(s>1e18):
    s=-1
print(s)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
a=1
for i in l:
  a=a*i
  if a>1000000000000000000:
    a=-1
    break
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 1
f = True
for i in A:
    ans *= i
    if ans > 10**18:
        f = False
        break
if f:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
li=list(map(int,input().split()))
ans=1
if 0 in li:
    print('-1')
    import sys
    sys.exit()
    
for l in li:
    ans*=l
    #print(ans)
    if ans > 10**18:
        print('-1')
        break
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
cumul = 1
n = int(raw_input())
ais = map(int, raw_input().split(' '))
i = 0
while(i < len(ais) and cumul < 10 ** 18):
  cumul *= ais[i]
  i+=1
print cumul if cumul < 10 ** 18 else -1

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

if 0 in a:
    ans = 0
else:
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10**18:
            ans = -1
        break
        
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(N):
  ans *= a[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
x = 1
for i in a:
    x *= i
    if x > 10**18:
        print(-1)
        exit()
print(x)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    LIM = 10**18
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans>LIM:
            print(-1)
            return
    print(int(ans))


main()

Submission status: Wrong Answer

Solution code:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
A=nl()

ans=1
for i in A:
    ans*=i
    if(10**18<ans):
        print(-1)
        sys.exit(0)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

rInt       = lambda : int(stdin.readline().strip("\n"))
rIntArray  = lambda : [int(x) for x in stdin.readline().split()]

rString    = lambda : stdin.readline().strip("\n")
rStrArray  = lambda : [x for x in stdin.readline().split()]

# for _ in range(rInt()):

n = rInt()
arr = rIntArray()

prod = 1
for i in arr:
	prod *= i
	if prod > 10**18:
		print(-1)
		quit()

print(prod)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = a[0]
for v in a[1:]:
    ans *= v
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1
limit = 10**18
for x in input().split():
    x = int(x)
    ans *= x
    if(ans > limit):
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
#B
n = int(input())
a = list(map(int,input().split()))
flg = True
MAX = 10 ** 18
cnt = 1
for i in range(n):
    cnt = cnt*a[i]
    if cnt > MAX:
        flg = False
        break

if flg:
    print(cnt)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
"""
~~ Author : Bhaskar
~~ Dated : 31~05~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    n = int(sys.stdin.readline())
    a = list(map(int,sys.stdin.readline().split()))
    ans=  1
    flag = False
    for i in a:
        ans *= i
        if ans > 10**18:
            flag = True
            break
    print(ans if not flag else -1)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
for a in A:
    ans = ans * a
    if (ans > 10 ** 18):
        print(-1)
        exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

border = pow(10, 18)

if 0 in A:
    print(0)
    exit()

ans = 1
for i in range(N):
    ans *= A[i]
    print(ans)
    if ans > border:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))

ans=1

for i in a:
    ans*=i
    if ans > 10 ** 18: 
        ans = -1
        break
    
print(ans)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int,input().split()))
c=1
for i in range(a):
    c*=b[i]
    if c>1000000000000000000:
        print(-1)
        break
else:
    print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
lim = int(1e+18)
for i in range(n):
    ans *= a[i]
    if lim < ans:
        print(-1)
        exit()
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())

ans = 1

for x in a:
    ans *= x
    if ans > 1000000000000000000:
        break

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1
for a in list(map(int, input().split())):
    if ans * a > 10**18:
        print(-1)
        exit()
    else:
        ans *= a
print(ans)

Submission status: Wrong Answer

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