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: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD
combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''
"#a,bの最大公約数"
def gcd(a, b):
    while b:#0以外なら進んでいくが、0になった時にとまる余りが0より、最大公約数と言える
        #print(a,b)#2,3
        #やり方てきにユークリッドの互除法か
        a, b = b, a % b#aには2 bには2%3が入る
    return a

"#a,bの最小公倍数"
def lcm(a, b):
    return a * b // gcd (a, b)

"#nの約数を全て求める"
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
'''
引数endに任意の文字列を指定すると、その文字列が改行の代わりに最後に挿入される。例えば連続するprint()の出力を改行なしで単純に連結したい場合は空文字列''を指定すればよい。

print('abc', end='---')
print('xyz')
# abc---xyz

print('abc', end='')
print('xyz')
# abcxyz
source: print_basic.py
なお、デフォルトで改行されるのは引数endのデフォルト値が改行文字'\n'に設定されているから。
'''

def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    #lenを変数に置くと事故るから注意
    n=int(input())
    #a,b=input().split(#" ")#a,bがともに文字列のとき
    #a,b=map(int, input().split(" "))
    #mapでとってもstrで変換すればappend可能
    #s=input()
    #a=[i for i in s]#int(i)にすれば数字も行ける
    nl=list(map(int, input().split(" ")))#数字の時
    #print(a)
    #brray=[list(map(int, input().split(" ")))for i in range(n)]
    #print(brray)
    n=len(nl)
    ans=1
    #from itertools import accumulate

#a = list(range(1, 11))
    #ans = list(accumulate(nl))     # itertoolsの戻り値はイテレータとなっているので必要に応じてlist化します．
    #print(a)
    #print(b)
    for i in range(n):
        ans=ans*nl[i]
    if ans>10**(18):
        print(-1)
        sys.exit()
    print(ans)
    #for i in range(1,n+1,2):#これで1個飛ばしループになる
    # pass
     #print(i)

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')#ある要素のインデックス番号を取得
    #s = ''.join(l)
    #s = " ".join(map(str,a))#スペースを空ける時はこう
    #print(s)
    # aaabbbccc

    #if state in known_states and not flag: # state => 2 steps => 5
        #こうやってある要素がリストの中にあるか探すのか
    #print(f'steps: {steps}, state: {state}')
    #こう書いてあるとデバックしやすい

    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

for A in As:

  if ans == 0:
    print(0)
    quit()
  else:
    ans = ans*A

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

Submission status: Runtime Error

Solution code:


#include <bits/stdc++.h>


using namespace std;
using ll = int64_t;
#define int int64_t

 
/* ==== declarations ====== */
// functions
void solve();
void getInput();
 
// global variables
int N;
vector<int> A;

/* ======================== */
void getInput() {
    cin>>N;
    A = vector<int>(N, 0);
    for (int i=0; i<N; ++i) {
        cin>>A[i];
    }
}
 
 
void solve() {
    int ans = 1;
    int lim = 1000000000000000000;
    for(auto a: A) {
        if (ans > lim and a != 0) continue;
        ans *= a;
    }
    if (ans > lim) {
        cout<<-1<<endl;
    } else {
        cout<<ans<<endl;
    }
}
 
 
 
signed main(){
    getInput();
    solve();
    return 0;
}

Submission status: Runtime Error

Solution code:
m=int(input())
lis = [int(input()) for x in range(m)]
ans=1
for x in lis:
    ans*=x
    if ans>=10**18:
        ans=-1
        break
print(ans)

Submission status: Runtime Error

Solution code:
t = int(input())
ans = 1
l=[]
for _ in range(t):
    n = int(input())
    l.append(n)
for i in l:
    ans = ans * i
if ans==0: print(0)
elif ans>1000000000000000000: print(-1)
else: print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(n) for n in input().split()]
ans = 1

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n=int(input())
arr=list(map(int, input().split()))
done=False
if 0 in arr:
  print("0")
else:
  mul=1
  for i in range(len(arr)):
    if mul*arr[i]<=int(1e18):
      mul*=arr[i]
    else:
      print("-1")
      done=True
      break
if not done:
  print(mul)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(input().split())
ans = A[0]
z = ("0" in A)

if(z == 1):
    ans = 0
elif(N >= 3 and z != 1):
    for i in range(1, N-1):
        ans = ans * int(A[i])
elif(N < 3 and z != 1):
    ans = int(A[0]) * int(A[1])


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

Submission status: Runtime Error

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

for i in N:
  Seki = Seki*A[i]
  if Seki > 10**18:
    break

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
x=1
for i in A:
  x*=i
	if x>1000000000000000000:
  	print('-1')
    break
else:
  print(x)

Submission status: Runtime Error

Solution code:
n = int(input())
x = [int(input()) for i in range(n)]

ans = 1
for i in x:
  ans = ans*i
  
if ans > 1000000000000000000:
  ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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


thr = 10**18

res = np.prod(A)

if res > thr:
    res = -1

print(int(res))

Submission status: Runtime Error

Solution code:
import math

n = int(raw_input()) 
arr = [int(x) for x in raw_input().split()] 
newpatient = 1
total = 1
for x in arr:
    total*=x

if(total>1000000000000000000):
    total=-1;
print(total)

Submission status: Runtime Error

Solution code:
n = (int)input()
p = 1
for i in range(n):
  x = (int)input()
  p = p*x

if p > 1000000000000000000:
  print("-1")
else:
  print(p)

Submission status: Runtime Error

Solution code:
import functools
import operator

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

result = functools.reduce(operator.mul, A)

if result > 10^18:
  print("-1")
else:
  print(ANS)

Submission status: Runtime Error

Solution code:
a = input()
f = 1
flag = 0
for x in range(0,a):
  b = input()
  f = f*b
  if f>1000000000000000000:
    flag = 1
  break
if f==0:
  print(0)
elif flag == 1:
  print('-1')
else:
  print(f)

Submission status: Runtime Error

Solution code:
a, b = map(int,input().split())
print(a*b)

Submission status: Runtime Error

Solution code:
t = int(input())
ans = 1
for _ in range(t):
    n = int(input())
    ans = ans * n
if ans==0: print(0)
elif ans>1000000000000000000: print(-1)
else: print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= abs(i)

if 10 ** 18 < total:
  print('-1')
else:
  print(sign * total)

Submission status: Runtime Error

Solution code:
import  numpy as mul
import math

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

if int(math.log10(ans)) > 17:
	print("-1")
else:
	print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import numpy as np

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


thr = 10**18

res = np.prod(A)

if res > thr:
    res = -1

print(int(res))

Submission status: Runtime Error

Solution code:
int(b[i])

Submission status: Runtime Error

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

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

for i in range(N):
    multiple *= A[i]
    if multiple > 10 ** 18:
        print(-1)
        sys.exit( )

print(multiple)

Submission status: Runtime Error

Solution code:
N = int(input())
input_line = list(map(int,input().split()))
input_line = list(map(int,input.split()))
ans = 1
if 0 in input_line:
    print(0)
else :
    for i in input_line:
        ans = ans * i
    if ans <= 10 ** 18 :
        print(ans)
    else :
        print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = [map(int, input().split())]
A.sort()

ans = 0
if(A[0] == 0):
    ans = 0
else:
    ans = np.prod(x)

if ans >= 1e18:
    print('-1')
else:
    print(f'{ans}')

Submission status: Runtime Error

Solution code:
import reduce

n = int(input())

a_list = [int(x) for x in input().split(" ")]

if len(a_list) != n:
  print("err")
  exit()

mult = reduce(lambda x, y: x * y, a_list)

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

Submission status: Runtime Error

Solution code:
def main():
	list = []
	n = int(input())
	for i in range (0,n):
		ele = int(input())
		list.append(ele)
	list.sort()
	ans = int(1)
	b = 0
	for i in range (0, n):
		ans = ans * list[i]
		if int(ans) > int(1000000000000000000):
			print(-1)
			return
	print(ans)
	return

if __name__ == "__main__":
  #Run as main program
  main()

Submission status: Runtime Error

Solution code:
n = input()
a = input().split(' ')
def doit(a):
  m = 1
  for ai in a:
  	if m > 10**18:
      return -1
    m = m*a
  
  return m

doit(a)

Submission status: Runtime Error

Solution code:
# your code goes here
n = int(raw_input())
nums = raw_input().split()
ans = 1
for i in range(len(nums)):
	ans = ans*int(nums[i])
if ans>1e18:
	print(-1)
else:
	print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
over_value = 10 ** 18 + 1
total = 1
if A.index(0):
    print(0)
else:
    for i in A:
        total *= i
    if total > over_value:
        total = -1
    print(total)

Submission status: Runtime Error

Solution code:
n = int(input())
x = [input() for i in range(n)]

ans = 1
for i in x:
  ans = ans*i
  
if ans > 1000000000000000000:
  ans = -1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
lista=[]
p=input().split()
for i in range(N):
  print(p[i])
  lista.append(p[i])
if np.prod(lista)<10**18:
  print(np.prod(lista))
else:
  print(-1)

Submission status: Runtime Error

Solution code:
n = int(input());
ans = 1;
for i in range(n):
    a = int(input())
    ans*=a
if ans>=1000000000000000001:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
list = list(map(int, input().split()))
no = 1
ans = list[0]
for i in range(N):
  ans = ans*list[no]
  no += 1
print(ans if ans <= 10**18 else "-1")

Submission status: Runtime Error

Solution code:
# Nの入力
N = int(input())

# A1,A2,..Anの入力
A = list(map(int,input().split())
         
# A1,A2...Anの積
A_multi = 1
for a in A:
    A_multi *= a

if a > 10**18:
    print("-1")
else:
    print(A_multi)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
newpatient = 1
total = 1
for i in range(0, n):
    x = int(input())
    total*=x

if(total>1000000000000000000):
    total=-1;
print(total)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans=1
i=0
while ans<=1000000000000000000:
    ans=ans*A[i]
    i+=1

if A.count(0)>0:
    print(0)
else:
    print(ans if ans<=1000000000000000000 else "-1")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections
import numpy
from decimal import *

def main():
    max_n = 10**18
    n = int(input())
    a = input_list()
    if 0 in a:
        print(0)
        exit()

    ans = numpy.prod(a)
    if ans > max_n:
        print(-1)
    else:
        print(int(ans))

def input_list():
    return list(map(Decimal, input().split()))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
list = [int(i) for i in input().split()]

ans = 1
flag = True
for i in range(n):
    if i%2==0:
        right *= list[i]
    else:
        left *= list[i]

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

Submission status: Runtime Error

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

for i in range(N):
  ans = ans * A[i]
  if ans = 0:
    break

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

Submission status: Runtime Error

Solution code:
n=input()
ans=1;
for i in range (0, n):
  x=input();
  ans*=x;
  if(x>1000000000000000000)
  	ans=-1
    break
print(ans)

Submission status: Runtime Error

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

ans = 1

for i in range(n):
    ans *= a[i]
if math.log10(ans) > 17:
     print(-1)
else:
     print(ans)

Submission status: Runtime Error

Solution code:
import math
a, b = map(float, input().split())
print(math.floor(a*b))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= abs(i)
  if 10 ** 18 < total:
    print('-1')
    quit()

print(sign * total)

Submission status: Runtime Error

Solution code:
import operator


a = list(input().split())

ans = reduce(operator.mul, a, 1)

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
#print(a)
#import functools
#import operator
import numpy

result = np.prod(a)

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split(" ")
lista = [int(n) for n in a]
if 0 in lista:
  print(0)
  exit()
kotae=1
for i in range(n+1):
  kotae=kotae*lista[i]
  if kotae>10**18:
    print(-1)
    exit()
print(kotae)

Submission status: Runtime Error

Solution code:
from operator import mul
 
n = int(input())
a = list(map(int,input().split()))
x = reduce(mul, a[:n])
if x > 10 ^ 18:
  print('-1')
else:
  print(x)

Submission status: Runtime Error

Solution code:
import collections
N=int(input())
A=list(map(int, input().split()))
A_dict=collections.Counter(A)
ASN=0
for i in A_dict.keys():
    ANS+=i**A_dict[i]

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(input().split())
ans=1
for i in a:
    ans=ans*int(i)
    if f==0 and ans>1000000000000000000:
        f=1
    if int(i)==0:
        f=0
        print(0)
if f==1:
    print(-1)
    exit()
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = 10 ** 18

ans = 1

for i in range(0, n):
    if a[i] == 0:
        print(0)
        exit()

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


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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    __uint128_t ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= a[i];
    }
    if (ans > (__uint128_t)LINF) {
        cout << -1 << endl;
    } else {
        cout << (ll)ans << endl;
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 21:01:07 2020

@author: liang
"""

import math

N = int(input())
A = list(map(int,input().split()))
B  = [math.log10(x) for x in A]

ans = 1
if sum(B) > 18:
    ans = -1
else:
    for a in A:
        ans *= a

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define xx first
#define yy second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n, p;
    cin >> n;

    ll x=1, yes=0, mx = 3000000000000000000;
    for(int i=0;i<n;i++)
    {
        cin >> p;

        if(p!=0 && (ll)(mx/p) <= x)
        {
            yes=1;
        }

        x*=p;
    }

    if(x == 0)cout << 0 << endl;
    else if(yes) cout << -1 << endl;
    else if(x<=1000000000000000000) cout << x << endl;
    else cout << -1 << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

a = sys.stdin.readline().strip()
arr = map(int, sys.stdin.readline().strip().split())
mod = 10**18

ans = arr[0]
for i in range(1, len(arr)):
    ans *= arr[i]
    if ans > mod:
        ans = -1
        break

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
la = list(map(int, input().split()))
import sys
if la.index(0) > 0:
  print(0)
  sys.exit()

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

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
M = 10**18
if 0 in a:
	print(0)
	break
else:
	ans = reduce(mul, a)
	if ans > M:
		print(-1)
		break
	else:
		print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = input()
a = A.split()
sum = 1
for i in range(N):
    sum *= int(a[i])
    if sum > 10**18:
        print(-1)
        flag = 1
        break
if flag == 0:
    print(sum)

Submission status: Runtime Error

Solution code:
n=int(input())
x=int(1)
for i=1:n
    b=int(input())
    x=x*b
if s>1000000000000000000
    s=-1
print(s)

Submission status: Runtime Error

Solution code:
import reduce

n = int(input())

a_list = [int(x) for x in input().split(" ")]

if len(a_list) != n:
  print("err")
  exit()

mult = reduce(lambda x, y: x * y, a_list)

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

Submission status: Runtime Error

Solution code:
input1 = input()
input2 = input()
A_list = [int(digit) for digit in input2.split(" ")]
product = 1
for i in range(N):
  product *= A_list[i]

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

Submission status: Runtime Error

Solution code:
import numpy as np

if __name__ == "__main__":
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ret = A.prod()
    print(ret if ret < pow(10, 18) else -1)

Submission status: Runtime Error

Solution code:

def main():
    N = map(int,input())
    A = list(map(int,input().split(' ')))
    if 0 in A:
        print(0)
        exit(-1)
    MAX = 10**18
    ans = 1
    for a in A:
        ans *= a
    if ans > MAX:
        print(-1)
    else:    
        print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
i=0
con=1
mod=10**18
ans=1
why=0
while con==1:
  ans=ans*a[i]
  i+=1
  if ans>mod:
    ans=1
    why=1
  elif i==n:
    con=0
if ans==0:
  print(0)
elif why==1:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
if 0 in A: print(0)
else:
    A.sort()
    ans=A.pop(-1)
    for i in range(N-1):
        ans=ans*A[N-(i+2)]
        if ans > (10**18): break
        if ans == 0: break
print(ans if ans<=10**18 else -1)

Submission status: Runtime Error

Solution code:
from functools import reduce
import array
b = int(input())
a= array.array("i",[int(x) for x in input().split()])

mm = reduce(lambda x, y: x * y, a) 

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
ans=1
for i in range(n):
  a = int(input())
  if ans!=-1:
    ans=ans*a
  if ans>1000000000000000000:
    ans=-1
print(ans)

Submission status: Runtime Error

Solution code:
A, B= map(float, input().split())
print(int(A*B))

Submission status: Runtime Error

Solution code:
a=int(input())
mul=1
l=[int(input()) for i in range(a)]


for i in l:
  mul=mul*i
if mul>1000000000000000000:
  print('-1')
else:
  print(mul)

Submission status: Runtime Error

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

def mp(a):
    b=[]
    if len(a)%2==0:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
    else:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
        b.append(a[len(a)//2+1]) 
    return b

b=a.copy()
while len(b)<=1:
    b=mp(b)   
    
if ap<=10**18:
    print(ap)
else:
    print(-1)