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:
import math

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

if 0 not in A:
  for i in A:
    l.append(math.log10(A[i]))
  if sum(l)<18: 
    print(int(10**sum(l)))
  else:
    print(str(-1))
else:
  print(str(0))

Submission status: Runtime Error

Solution code:
import math

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

if 0 not in A:
  for i in A:
  l.append(math.log10(A[i]))
  if sum(l)<18: 
    print(int(10**sum(l)))
  else:
    print(‘-1’)
else:
  print(‘0’)

Submission status: Runtime Error

Solution code:
import math

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

for i in A:
  l.append(math.log10(A[i]))
  
if sum(l)<18:
  print(int(10**sum(l)))
else:
  print(-1)

Submission status: Runtime Error

Solution code:
import.math

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

for _ in A:
  l.append(math.log10(A))
  
if sum(l)<18:
  print(math.exp(sum(l)))
else:
  print(-1)

Submission status: Runtime Error

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

for i in range(n):
    ans *= a[i]

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

Submission status: Runtime Error

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

MAX = 10**18
result = 1
for i in input().split():
    result *= i

if result > MAX:
    print(-1)
else:
    print(result)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>1000000000000000000:
            s=-1
            break
            
     print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>1000000000000000000:
            s=1
            
print(s)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
if min(l)=0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
    
    if s>1000000000000000000:
        print(-1)
    else:
        print(s)

Submission status: Runtime Error

Solution code:
N = input()
M = list(map(int,input().split()))
    
mult = 1
 
if 0 in A:
  print(0)
  return

for a in M:
    mult *= a
    if mult> 1000000000000000000:
        print(-1)
        
print(mult)

Submission status: Runtime Error

Solution code:
X, Y = map(int, input().split())

result = "No"
for i in range(X + 1):
    if 2 * i + (X - i) * 4 == Y:
        result = "Yes"

print(result)

Submission status: Runtime Error

Solution code:
/*
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define pii pair<int, int>
#define rep(s, e) for (int i = s; i < e; i++)
#define reep(s, e) for (int i = s; i <= e; i++)
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define Hiraishin                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
using namespace std;

// global
const int mx = 1ull * pow(10, 18);

void solve()
{
    int n;
    cin >> n;
    int res = 1ull;
    while (n--) {
        int t;
        cin >> t;
        res *= t;
    }
    cout << (res <= mx ? res : -1);
}

signed main()
{
    Hiraishin
    //tests
    solve();
    return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
m = int(input().split(" "))
for i in range (n):#to multiply the content i m
    total=1
    for x in m:
        total *= m

if total<1_000_000_000_000_000:#to set that it will not exceed  10^15
    print(total)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
n = int(input())
m = int(input().split(" "))
for i in range n:
    total=1
    for x in m:
        total *= m

if total<10000000000000000
    print(total)
else:
    print("-1")

Submission status: Runtime Error

Solution code:

z=0
total=1
N=int(input()) #take the N value
    
while z<N: #show how many number of multiplication
    A=int(input()) #Inout from user
    total*=A #multiplication
    z+=1 #increment
    
num1=10**18   
num2=10**5

if N>=2 and N<=num2: #make sure input N is 2<=N<=10^5
    if A>=0 and A<=num1: #make sure input A is 1<A<10^18
        if total>num1:
            print(-1) #over the limit, show -1
            
            
        else:
            print(total) #inside limit, show total
    else:   
        print('Wrong input') #tell the user that the input is wrong
else:
    print('Wrong input') #tell the user that the input is wrong

Submission status: Runtime Error

Solution code:
from array import*

amountOfInput= input()

x= len(amountOfInput)
num= array('i',[])
lengthNum= len(num)

for i in range (x):

    num1= input().split()
    num1.append(num)
i+=1

for i in range (lengthNum):

    result= num[i]*num[i+1]

    if result <= 1000000000000000000:

        print(num[-1])

    else:
        print(result)

i+=1

Submission status: Runtime Error

Solution code:
def mulallnumber(numbers): #Function to multiply all numbers in list
   x=1
   for i in numbers:
      x*=i
      return x

A=list() #Creates a list

N=int(input("Enter the size of the list ::")) #size of list

print("Enter the element of list ::")
for i in range(int(N)):
   k=int(input(""))
   A.append(k) #append number in list

if mulallnumber(A)<1000000000000000000:
    print(mulallnumber(A))
else:
    print('-1') #will print '-1' if it exceeds 10^18

Submission status: Runtime Error

Solution code:
def mulallnumber(lst):
   x=1
   for i in lst:
      x=x*i
      return x

A=list()

N=int(input("Enter the size of the list ::"))

print("Enter the element of list ::")
for i in range(int(N)):
   k=int(input(""))
   A.append(k)

if mulallnumber(A)<1000000000000000000:
    print(mulallnumber(A))
else:
    print('-1')

Submission status: Runtime Error

Solution code:
#declare integer N and A
#if the result more than 1000000000000000000 the result will be -1

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


result = 1
for a in A:
       result *= a
                if result > 1000000000000000000:
                           print(-1)

print(result)

Submission status: Runtime Error

Solution code:
a=int(input())
tem = 1

if a != 0:
    b=input().split(" ")
    for i in range(a):
        tem = tem * int(b[i])
    if len(tem)> 10**18:
        tem = -1
print(tem)

Submission status: Runtime Error

Solution code:
import numpy as np
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

Submission status: Runtime Error

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

if 0 in A:
    print(0)
    return 

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        return 

print(Π)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,s=0; cin>>n; while (n--){
        int a; cin>>a;
        s *= a;
        if (s==0){
            cout << 0;
            return;
        }
    }
    if (s>pow(10,18) or s<0) cout << -1;
    else cout << s <<endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}

Submission status: Runtime Error

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

cnt = 1

if a in 0:
    print(-1)
else:
    for i in range(n):
        cnt = cnt * a[i]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = input()
n = list(map(int, input().split()))
import numpy as np
if np.prod(n) =>10 ** 18:
  print('-1')
else:
  print(np.prod(n))

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))
if a.count(0) > 0:
    aa = 0
else:
    aa = math.prod(a)
if aa > 10**18:
    print(-1)
else:
    print(aa)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))
aa = math.prod(a)
if aa > 10**18:
    print(-1)
else:
    print(aa)

Submission status: Runtime Error

Solution code:
N = int(input())

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

Submission status: Runtime Error

Solution code:
n = int(input())
arr = list(map(int,input().split()))
arr.sort(reverse=True)
ans = 1
limit = 10 * 18

if arr[-1] == 0:
  ans = 0
else:
  for i in arr:
    ans *= arr[i]
    if ans > limit:
      ans = -1
      break
print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,j,n) for(int i = (int)(j); i < (int)(n); i++)
#define mrep(i,n) for (int i = (int)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define scout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll MAX=1e18;

int main() {
	int n; cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
  	sort(be(a)); reverse(be(a));
	ll ans=1;
	rep(i,n) {
		ll li=MAX/ans;
		if(a[i]>li) {
			cout << -1 << endl;
			return 0;
		}
		ans*=a[i];
	}
	cout << ans << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int, input().split())
ans = a[0]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VLL A(n);
  INPUT(A);
  if (MIN(A) == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  LL s = 1;
  REP(int, i, n)
  {
    s *= A[i];
    if (s > 1000000000000000000)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << s << endl;

  return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split(' ')))
if a.index(0) >= 0:
	print(0)
else:
	lim = int(1e18)
	mult = 1
	for v in a:
		if mult > lim:
			break
		else:
			mult *= v
	if mult > lim:
		print("-1")
	else:
		print(mult)

Submission status: Runtime Error

Solution code:
import sys
 
input = sys.stdin.readline
 
n = int(input())
a = list(map(int, input().strip().split()))
if(0 in a):
 print(0)
 return
else:
 ans = 1
 for ai in a:
  ans *= ai
  if(ans > 10**18):
   print(-1)
   return

 print(ans)

Submission status: Runtime Error

Solution code:
a=int(input())
b=input()
lst2=b.split()
if 0 in lst2:
  print(0)
  return

pro=1
for i in lst2:
    pro*=int(i)

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

Submission status: Runtime Error

Solution code:
a=int(input())
b=input()
lst2=b.split()
if 0 in lst2:
  print(0)
  return 0
pro=1
for i in lst2:
    pro*=int(i)

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

Submission status: Runtime Error

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

answer = 1
if 0 in A:
  print(0)
  break
else:
  for i in A:
    answer *= i
  if answer > 10**18:
    print(-1)
  else:
    print(answer)

Submission status: Runtime Error

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

answer = 1
if 0 in A:
  print(0)
else:
  for i in A:
    answer *= i
    if answer > 10**18:
      print(-1)
      exit()
	print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

digits=0
ans=1

for i in list:
  digits+=len(i)
  if digits >=18:
   print(-1)
  else:
    ans=ans*i

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = input()

str_list = list(input().split())

P = np.prod(str_list)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from functools import reduce
n = input()
arr = list(map(int, input()))
res = reduce(lambda x, y: x*y, arr)
if res >= 10*18:
  print("-1")
else:
  print(res)

Submission status: Runtime Error

Solution code:
def main():
  
	N = int(input())
	A = sorted(list(map(int, input().split())))
	A_ = 1
 
	for i in A:
    	A_ *= i
        
	if A_ > 1000000000000000000:
    	print(-1)
	else:
    	print(A_)
main()

Submission status: Runtime Error

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

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        values *= a
        if prod >  1000000000000000000:
            print('-1')
            return
    print(prod)
main()

Submission status: Runtime Error

Solution code:
n=int(input())
arr=list(map(int,input().split())
x=int(1)
for ele in arr: x = x*int(ele)
if x>1000000000000000000: print(-1)
else : print(x)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
num = list(map(int,input().split()))
for l in range(len(num)):
    ans *= num[l] 
if ans < 10**18:
    print(ans)
elif ans >= 10**18:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x=int(input())
y, z=map(int, input().split())
if y*z > 10**18:
  print(-1)
else:
  print(y*z)

Submission status: Runtime Error

Solution code:
import math
N=int(input())
A=list(map(int,input().split()))
x=0
if 0 in A:
    y=True
    A.remove(0)
for i in A:
    x+=math.log(i,10)
if y==True:
    print(0)
elif x<=18.1:
    prod=1
    for i in A:
        prod=prod*i
    if prod<1e18:
        print(prod)
else:
    print('-1')

Submission status: Runtime Error

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

    for i in range(n):
        ans = ans * list[i]
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)


main()

Submission status: Runtime Error

Solution code:

n = int(input())
ans =1
while n>0:
    x = int(input())
    ans *= x
    n-=1
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
input = stdin.readline
def main():
  n = int(input())
  a = list(map(int,input().split())).sort()
  if a[0] == 0:
    print(0)
    return
  ret = 1
  for i in a:
    ret *= i
    if ret > 10**18:
      print(-1)
      return
  print(ret)
main()

Submission status: Runtime Error

Solution code:
input()
a=1
b=map(int,inpit().split())
for i in b:
  a*=i
if a>10^18:
  a=-1
print(a)

Submission status: Runtime Error

Solution code:
# 169 B

import math
n = int(input())
a = list(map(int, input().split()))
p = 1
x = True

p = math.product(a)
if p > (10 ** 18):
    x = False


if x == True:
    print(p)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
N = int(input())
mylist = (input().split(" "))
result = 1

if 0 in mylist:
    result = 0

else:
    for i in mylist:
        
        if result > 10 ** 18:
            result = -1
            break
        else:
            result *= i
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

int main(){
  long long N;
  cin >>N;
  
  
  vector<long long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  
  sort(begin(A),end(A));
  
  long long answer=1;
  for(int i=0; i<N; i++){
    answer*=A[i];
  }
  
  if(answer>1000000000000000000){
  	cout<< -1 << endl;
  }else{
    cout << answer << endl;
  }
  
}

Submission status: Runtime Error

Solution code:
import sys
readline = sys.stdin.buffer.readline
n = int(readline())
a = map(int, readline().split())
a.sort()
v = 1
for i in a:
  v *= i
  if v > 1000000000000000000:
    print(-1)
    break
  elif v == 0:
    print(0)
    break
else:
  print(v)

Submission status: Runtime Error

Solution code:
n = int(input())
arr = input().split()
def mult():
	if 0 in arr:
  		print(0)
        return 0
    a = 1
    for i in arr:
      a = a * i
    if a > 1000000000000000000:
      print(-1)
      return 0
    else: 
      print(a)
      return 0

mult()

Submission status: Runtime Error

Solution code:
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr: print(0)
else:
	prod = 1
	for i in arr:
		count *= i
	if count > 1000000000000000000: count = -1
	print(count)

Submission status: Runtime Error

Solution code:
n = int(input())

arr = input().split()
count = 1
if "0" in arr:
  count = 0
else: for i in arr:
        count *= int(i)
      if count > 1000000000000000000: count = -1
  
print(count)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(int(input()))
ans=1
if 0 in a:
  print(0)
else:
  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()))
 
ans = 1
 
for i in A:
  ans *= i
  
  if ans > 10 ** 18:
  print(-1)
  return 
  
 
  
print(ans)

Submission status: Runtime Error

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

  
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in N:
  ans *= A[i]
  
print(ans)

Submission status: Runtime Error

Solution code:
input()
a = list(map(int, input().split()))
ans = 1
for el in a:
    ans *= el
    if ans > 1e18:
        print(-1)
        return
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = 1
limit = 1e18
limit += 1
for i in range(n):
	ans = min(ans*a[i], limit)
    if(ans == limit):
    	ans = -1
print(ans)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
#define ll long long int
 
using namespace std;
 
int main(){
  ll n;
  cin>>n;
  ll arr[n];
  ll m =1;
  for(int i=0;i<n;i++){
    cin>> arr[i];
  }
  for(int i=0;i<n;i++){
    m = m* arr[i];
  }
  if(m <=1000000000000000000)
    cout<<m<<endl;
  else
    cout<<'-1'<<endl;
  return 0;
}

Submission status: Runtime Error

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

    if 0 in a:
        print( 0 )
        return

    ans = 1
    for b in a:
        ans = ans * b
        if( ans > 1000000000000000000 ):
            print( -1 )
            return
    print( ans )

main()

Submission status: Runtime Error

Solution code:
n = int( input())
ans = 1

for _ in range( n ):
    temp = int( input())
    if( temp == 0 ):
        ans = 0
        break
    if( ans * temp > 10 ** 18 ):
        ans = -1
        break
    ans = ans * temp

print( ans )

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2= 998244353;

void solve()
{
	ll n;
	cin>>n;
	__int128 p=1, o=1e18;
	VL v(n, 0);
	for(int i=0;i<n;i++) cin>>v[i];
	ll flag=0;
	for(auto t: v)
	{
		p*=t;
		if(p>o)
		{
			flag=1;
			break;
		}
	}
	if(flag)cout<<-1;
	else cout<<ll(p);
	
		
}
 
int main()
{
    IOS
    int _=1;
    //cin>>_;
    while(_--)
    {
	    solve();
    }
    
    return 0;
}

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
A.sort()
rslt = A[0]
 
for a in A[1:]:
  result *= a
  if rslt > 10**18:
    print(-1)
    exit()
print(rslt)

Submission status: Runtime Error

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

for a in A[1:]:
  result *= a
  if rslt > 10**18:
    print(-1)
    exit()
print(rslt)

Submission status: Runtime Error

Solution code:
N = input().strip()
A = [input().strip() for i in range(N)]

r = A[0]
for i in range(1,N):
  r *= A[i]

if r > 10**8: r = -1

  
r = int(r)
print(r)

Submission status: Runtime Error

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

if 0 in list:
  print(0)
else:
  prod=1
  for a in list:
    flg=True
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,'int64')
ans=np.prod(list)
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(np.prod(list))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,int)
ans=np.prod(list)
p=math.log10(ans)
if p>=18:
  print(-1)
else:
  print(np.prod(list))