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:
N= int(input())
lists = list(map(int,input().split()))
import math
#print(lists)
q=int(1)
for i in range(N):
    s = lists[i-1]
    q *= s
#print( math.log(q, 10))
if math.log10(q)>=18:
    print(-1)
else:
    print(q)

Submission status: Runtime Error

Solution code:
from collections import deque

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

if n%2==0:
	ans=1
	for i in range(n/2):
		ans=ans*a[i]*a[i+n/2]
else:
	if n==1:
		ans=a[0]
	else:
		ans=a[0]
		for i in range(1,int((n-1)/2)+1):
			ans=ans*a[i]*a[i+int((n-1)/2)]

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

Submission status: Runtime Error

Solution code:
from math import prod
n = int(input())

a = list(map(int,input().split()))
new = math.prod(a,start=0)
val = pow(10,18)
if new > val:
	print(-1)
else:
	print(new)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input()
a = a.replace(' ','*')
result = 1
result = eval(a + "*result")
print("-1" if result > 1000000000000000000 else result)

Submission status: Runtime Error

Solution code:
n = raw_input()
ans=1
for i in range(n):
  tmp = raw_input()
  ans= ans * tmp;
if ans>1000000000000000000:
  print("-1")
else:
  print(ans)

Submission status: Runtime Error

Solution code:
a = int(input())
b = float(input())
c = int(a * b)
print(c)

Submission status: Runtime Error

Solution code:
n = int(input())
res = 1
list = []
for i in range(n):
    list.append(input())
for j in list:
    x = int(j)
    res = res*x
if res < 1000000000000000000:
    print(res)
else:
    print("-1")

Submission status: Runtime Error

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


t= False

for i in a:
    if i==0:
        print(0)
        t = true
ans = 1
end = 10**18
if not t:
    for i in a:
        if float(ans) > float(end/i):
            t = True
            break
        ans *= i;
    if t or ans>end:
        print(-1)
    else:
        print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 1
for num in A
	ans*=num
print(num)

Submission status: Runtime Error

Solution code:
N= int(input())
lists = list(map(int,input().split()))
import math
#print(lists)
q=int(1)
for i in range(N):
    s = lists[i-1]
    #print(s)
    q *= s
    if math.log10(q)<18:
        print(-1)
        break
    else:
        print(q)

Submission status: Runtime Error

Solution code:
import functools
import operator
n=int(input())
li = list(map(int, input().split()))
if (len(li)<=80):
    result = functools.reduce(operator.mul, li)
    if (result > (1000000000000000000)):
        print(-1)
    else:
        print(result)

elif (result > (1000000000000000000)):
    print(-1)
else :
    print(result)

Submission status: Runtime Error

Solution code:
n int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  continue
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)

Submission status: Runtime Error

Solution code:
from math import prod
n = int(input())

a = list(map(int,input().split()))
new = math.prod(a)
val = pow(10,18)
if new > val:
	print(-1)
else:
	print(new)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

ans = 1
for i in range(n):
    a = int(input())
    ans *= a

if ans > 10**18:
    ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
L=list(map(int,input().split()))
L=np.prod(L)

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

Submission status: Runtime Error

Solution code:
import sys
N=int(sys.stdin.readline()) 
values = []
res = 1
while N :
	values=(sys.stdin.readline().split())
	for v in values:
      res *= v
    if res > 10e18:
      print(-1)
    else
      print(res)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 100005
#define PI 3.1415926535897932384626433
#define gcd(a,b) __gcd(a,b)

using namespace std;

ll power(ll x,ll y,ll p)
{
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}



int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);

    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        vector<ll> arr(n);
        forn(i,n) cin>>arr[i];
        forn(i,n) if(arr[i]==0){
        cout<<0;return 0;
        }
        ll ans=1;
        forn(i,n){
            ans*=arr[i];
            if(ans>(long long int)(1e18)){
                cout<<-1;return 0;
            }
        }
        cout<<ans;


    }


    return 0;
}

Submission status: Runtime Error

Solution code:
n = input()

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

total = 1

if a in 0:
	total = 0
else:
	for i in a:
		total *= i

if total > 10**18:
	total = -1

print(total)

Submission status: Runtime Error

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

import math

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

b = int(math.pow(10,18))

if int(math.log10(total))-18>0:
    print(-1)
else:
    print(total)

Submission status: Runtime Error

Solution code:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	a := intSliceScanner(n)
	sort.Ints(a)
	ans := 1
	for i := 0; i < n; i++ {
		x, y := strconv.Itoa(ans), strconv.Itoa(a[i])
		if len(x)+len(y) > 20 {
			ans = -1
			break
		}
		ans *= a[i]
		if ans > 1000000000000000000 {
			ans = -1
			break
		}
	}
	fmt.Println(ans)
}

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
mul=1;
for i in range(n):
  l.append(int(input()))
  mul=mul*l[i]
  if(mul>(10**18)):
    mul=-1
    break
print(mul)

Submission status: Runtime Error

Solution code:
import numpy as np

n=input()
a=list(map(int,input().split()))
a=np.array(a,dtype="float64")
ans=np.prod(a)

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

Submission status: Runtime Error

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

if nums.count(0) > 0:
  ans = 0
else:
  for i in range(n):
    ans *= nums[i]
    if ans >= 10**18:
      ans = -1
      break
  else:
    break
 
print(ans)

Submission status: Runtime Error

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n=getN()
a=getList()
x=max(a)
import numpy as np
c=np.array(a)/x
c_=np.prod(c)*x**n
if 0 in a:
    print(0)
elif c_<0 or c_>10**18:
    print(-1)
else:
    print(int(c_))

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
sum = 1
for i in range(n):
    b = int(input())
    if(b==0):
        sum = 0
    a.append(b)
if sum != 0:
    for i in range(n):
        sum *= a[i]
if(sum > 1000000000000000000):
    print(-1)
else:
    print(sum)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = list(input().split())
B = np.array(A,dtype='float64')
B = np.max(B)
if B>=2e18 :
    print("-1")
else:
    A=np.array(A,dtype='int64')
    ans=np.prod(A,dtype='int64')
    if ans >=np.int64(1e18) : flg = 1
    if ans<=np.int64(0)  : flg = 1
    if flg ==1:
        print(ans)
    else:
        print("-1")

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std; 
typedef long long int  ll;
#pragma GCC optimize("O3")
#define pb push_back

int32_t main()  {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n ;
	cin >> n ;
	ll ans = 1;
	ll k = 1000000000000000000;
	int fl =0;
	while ( n--)
	{
		ll in ;
		cin >> in;
		ans=ans*in;
		if(ans>k) {
			fl=1;}
		if(in==0){
			ans=0;
		}
		if(ans!=0)	
		if((k/ans)>in) {
			fl=1;
		}	
	}
	if(	fl==1 and ans!=0)
	cout<<-1<<endl;
	else
	cout << ans;
}

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = 1
for i in a:
  ans = ans * i
  if ans >= 1000000000000000000:
  	break:

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

Submission status: Runtime Error

Solution code:
def multiplyList(myList): 
    result = 1
    for x in myList: 
        result = result * x
        if(n > 1000000000000000000):
        	return 1000000000000000001
    return result 

t=int(input())
l=list(map(int,input().split()))
if 0 in l:
	print(0)
else:
	n = multiplyList(l)
	if(n > 1000000000000000000):
		print("-1")
	else:
		print(n)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(input().split())
ans=1
f=0
i=0
while(i<=n):
    if i==n-1:
        ans=ans*int(a[i])
    else:
        ans=ans*int(a[i])*int(a[i+1])
        i+=1
    if f==0 and ans>1000000000000000000:
        f=1
    if ans==0:
        print(0)
        exit()
    i+=2
if f==1:
    print(-1)
    exit()
print(ans)

Submission status: Runtime Error

Solution code:
package main

import "fmt"

func main() {
	var n int
	var ans int = 1
	fmt.Scan(&n)
	t := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}

	for i := 0; i < n; i++ {
		ans = ans * t[i]
	}

	if ans > 1000000000000000000 {
		ans = -1
	}
	fmt.Println(ans)
}

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [int(input()) for _ in range(N)]
B = np.array(A)
V = np.prod(B)
if V<= 10**18:
  print(V)
elif V>10**18:
  print('-1')

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=10**9
a=1
count=0
for i in range(n):
    a=a*l[i]
    if a//c>=2:
        print("-1")
        exit()
    elif a//c==1:
        a=a%c
        count=count+1


if count=0:
    print(a)
elif count=1:
    print(a*c)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
N = input(int())
ans = 1
i = []

list = [i for i in input().split()]

for a in range(N-1):
  ans = ans * i[a]

if ans > 10**18:
    ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
m = int(input())
n = input().split()
sorted(int(n))
ans=1
for i in n:
    ans*=i
    if ans==0:
        break
    elif ans >= 10**18:
        ans=-1
        break
    else:
        ans=-1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
upper = pow(10,18)
result = np.prod(np.array(A).astype('int64'))
if upper < result:
    print(-1)
else:
    print(int(result))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())

a=list(map(int,input().split()))
import functools
import operator

pre = functools.reduce(operator.mul, a)
if pre <= 1000000000000000000:
    print(pre)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
m = int(input())
n = input().split()
sorted(int(n))
ans=1
for i in s:
    ans*=i
    if ans==0:
        break
    elif ans >= 10**18:
        ans=-1
        break
    else:
        ans=-1
print(ans)

Submission status: Runtime Error

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

for i in a:
    if(i==0):
        print("-1")
        sys.exit
    sum*=i 

if(sum>pow(10,18)):
    print("-1")
else:
    print(sum)

Submission status: Runtime Error

Solution code:
from functools import reduce
from operator import mul

t = input() #trash
L = list(map(int, input().split()))
      
ans = reduce(lambda a, b: a*b, array)

if ans <= 1000000000000000000:
  print(ans)
else:
  print("-1")

Submission status: Runtime Error

Solution code:
program main
integer(8), allocatable :: x(:)
integer(8) :: N,S,A
A = 10**18_8
read *,N
allocate(x(N))
read *,x
S = 1
do i = 1, N
S = S * x(i)
end do

if ( S >= A ) then
	S = -1
end if
print '(i0)',S
end program main

Submission status: Runtime Error

Solution code:
N = int(input())
numbers = [int(n) for n in input().split()]
mlt = 1
if 0 in n:
    print(0)
for n in numbers:
    mlt *= n
    if mlt > 1000000000000000000:
        mlt = -1
        break
print(mlt)

Submission status: Runtime Error

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

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  elif 0 in A_n is False:
    print(-1)
  else:
    print(0)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce
import numpy as np

N = int(input())
A = [int(x) for x in input().split()]
#A = [np.multiply(x) for x in input().split()]

ans = reduce(mul,A)
#ans = np.multiply(A)
#ans = np.prod(A)

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

Submission status: Runtime Error

Solution code:
import numpy as np
N=map(int,input().split())
p=list(map,input().split())
x=np.prod(p)
if x<10**18:
  print(x)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
def multi(L):
  ans = 0
  for l in L:
  	if ans <=10**18:
      ans *= l
    else:
      ans = -1
      break
      
   return ans

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

print(multi(A_list))

Submission status: Runtime Error

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

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  elif "0" in A_n is False:
    print(-1)
  else:
    print(0)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
import numpy
import math
import collections
from decimal import *

def main():
    n = int(input())
    a = input_list()
    ca = collections.Counter(a)
    max_n = 10 ** 18
    if 0 in a:
        print(0)
        exit()
    ans = 1
    for num, count in ca.items():
        if num == 1:
            continue
        ans *= num**count
        if ans > max_n:
            print(-1)
            exit()
    print(ans)


def yogen(a, b, angle):
    coss = math.cos((angle/180)*math.pi)
    return math.sqrt(a**2 + b**2 - 2*a*b*coss)


def get_angle(hour, minute):
    h = (hour * 360) / 12 + (minute * 360) / (12 * 60)
    m = (minute * 360) / 60
    angle = abs(h-m)
    return min(angle, 360-angle)

def has(v, l):
    for vl in l:
        if v == vl:
            return True
    return False

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))
array = np.array(list_input)

a = array.prod()

if a > pow(10, 18):
    print(-1)
else:
    print(a)

Submission status: Runtime Error

Solution code:
a=int(input())
b=[]
c=1

for i in range(a):
  p=int(input())
  b.append(p)
for i in range(a):
  if(c>1000000000000000000):
    c=-1
    break
  elif(b[i]==0):
    c=0
    break
  else:
    c=c*b[i]
print(c)

Submission status: Runtime Error

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

for i in range(n):
    x = int(input())
    prod *= x
 
if prod<=1e18:
    print(prod)
else:
    print("-1")

Submission status: Runtime Error

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

for i in a:
    if(i==0):
        print("-1")
        return
    sum*=i 

if(sum>pow(10,18)):
    print("-1")
else:
    print(sum)

Submission status: Runtime Error

Solution code:
N = input(int())
ans = 1
i = []

list = [i for i in input().split()]

for a in range(N-1):
  ans = ans * i[a]

  if ans > 10**18:
    ans = -1

print(ans)

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(0)
else:
  kotae=1
  for i in range(n+1):
    kotae=kotae*lista[i]
    if kotae>10**18:
        print(-1)  
        exit(0)
  print(kotae)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
for _ in range(N):
  A = list(map(int,input().split()))
  B = np.array(A)
  V = np.prod(B)
if V<= 10**18:
  print(V)
elif V>10**18:
  print('-1')

Submission status: Runtime Error

Solution code:
import math
import numpy as np

n = int(input())
answer = 1
for i in range(n):
    a = input()
    answer = answer * int(a)
    if answer > 10**18:
        print("-1")
        break
print(answer)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  p = 1
  f = True
  for i in a:
    p *= i
    if(p > 1000000000000000000):
      f = false
      break
  if(f):
    print(p)
  else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())

a=list(map(int,input().split()))
c=np.array(a)
pre = abs(np.prod(c))
if pre <= 1000000000000000000:
    print(pre)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
def multiply( a , n ): 
	
	if n == 0: 
		return(a[n]) 
	else: 
		return (a[n] * multiply(a, n - 1)) 


n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n]
    
ans = multiply(a, n - 1)
if ans>1000000000000000000 : 
    print(-1)
else :
    print(ans)

Submission status: Runtime Error

Solution code:
import sys

def main(lines):
    N = int(lines[0])
    a = []
    ans = 1
    for i in range(N):
        a.append(int(lines[1][i]))
        if int(lines[1][i]) == 0:
            ans = 0

    for i in range(N):
        ans *= a[i]
    
    if a <= 1000000000000000000:
        print(ans)
    else:
        print("-1")


if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\n').split(" "))
    main(lines)

Submission status: Runtime Error

Solution code:
from sys import stdin

n = input()
a = [int(x) for x in stdin.readline().rstrip().split()]
ans = 1
for x in range(n):
    ans *= a[x]

if ans < 0 or ans >1000000000000000000:
    print("-1")
else:
    print(ans)

Submission status: Runtime Error

Solution code:
def multiplyList(myList): 
    result = 1
    for x in myList: 
        result = result * x 
        if(result > 1000000000000000000):
        	return 0
    return result 

t=int(input())
l=list(map(int,input().split()))
n = multiplyList(l)
if(n > 1000000000000000000 || n == 0):
    print("-1")
else:
    print(n)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
mul = 1
a = 0
while n>0 :
    a = int(input())
    mul = mul * a
    n -= 1

if mul <= 1000000000000000000:
    print(int(mul))
else:
    print('-1')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
num = list(map(int,input().split(" ")))
 
s = num[0]
 
for i range(1,n):
  s = s * num[i] 
 
print(s)

Submission status: Runtime Error

Solution code:
N = int(input())
    A = sorted([int(i) for i in input().split()])
    res=1
    for x in A:
        res = res*x
        if res > 10 ** 18:
            res = -1
            break
    print(res)

Submission status: Runtime Error

Solution code:
A = int(input())
B = float(input())
print(A * round(B,2))

Submission status: Runtime Error

Solution code:
n = input()
total = 1

for i in range(n):
  total *= input()

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

Submission status: Runtime Error

Solution code:
N = int(input())
 
num_list = input().split()
 
total = int(1)
if "0" in num_list:
  print(0)
  
else:
  for i in range(N):
    if len(str(total)) > 19:
      break
    else:
      total *= int(num_list[i])
if if len(str(total)) > 19:
  print(-1)
else:
  print(total)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    ll a,ans = 1;
    cin >> n;
    rep(i, n){
        cin >> a;
        ans *= a;
    }
    if(ans > 1000000000000000000) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Submission status: Runtime Error

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

s = num[0]

for i range(1,n):
  if len(str(s)) > 16:
    s = -1
    break
  s = s * num[i] 

print(s)

Submission status: Runtime Error

Solution code:
from decimal import Decimal
N=int(input())
A=[*map(str,input().split())]
a=Decimal('1')
while A:
  a=a*Decimal(A.pop())
  if a > Decimal('10'**'18'):
    print(-1)
    break
else:
  print(a)

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(10**6)
from decimal import Decimal
K = int(input())
N = input().split()

ans = Decimal(str(N[0]))
for A in N[1:]:
    A = Decimal(str(A))
    ans = ans * A

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N= int(input())
lists = list(map(int,input().split()))
import math
#print(lists)
q=int(1)
for i in range(N):
    s = lists[i-1]
    q *= s
    if math.log(q, 10)<18:
        print(-1)
        break
    else:
        print(q)

Submission status: Runtime Error

Solution code:
a=int(input())
b=[]
c=1
for i in range(a):
  p=int(input())
  if(p==0):
    c=0
    break
  else:
  	c=c*p
if(c>1000000000000000000):
  print("-1")
else:
  print(c)

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
list_a=np.array(map(int, input().split()))
print(np.prod(list_a))

Submission status: Runtime Error

Solution code:
def multiplyList(myList) : 
	
	# Multiply elements one by one 
	result = 1
	for x in myList: 
		result = result * x 
	return result 
	
# Driver code 
n=int(input())
lst=[]
for i in range(0, n): 
 	ele=int(input()) 
 	lst.append(ele)
ans=multiplyList(lst)
if ans>1000000000000000000:
  print("-1")
else:
  print(ans)

Submission status: Runtime Error

Solution code:
import math
A,B = input().split()
B = float(B)
new_B = "{:.2f}".format(B)
print(math.floor(int(A)*float(new_B)))

Submission status: Runtime Error

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

list = [i for i in input().split()]

for a in range(N-1):
  ans = ans * list[a]

  if ans > 10**18:
    ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
    
while i<n:
  while j < n:
  	if data[j]==0:
    	a = 0
    	break
    j +=1  
  a = a*data[i]
  i += 1

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

Submission status: Runtime Error

Solution code:
n=int(input())
lis=list(map(int, input().split()))
if 0 in lis:
  print(0)
  exit()
elif max(lis)>10**18:
  print(-1)
  exit()
 
def calc(i, h):
  if h>10**18:
    print(-1)
    exit()
  elif i==0:
    return(h)
  return h*calc(i-1, lis[i-1])
result=calc(n, 1)
print(result)

Submission status: Runtime Error

Solution code:
m = int(input())
n = input().split()
s=[]
for i in n:
    s.append(int(i))
    
s.sort()
ans=1
for i in s:
    ans*=i
    if ans==0:
        break
    if ans =< 10**18:
        continue
    else:
        ans=-1
print(ans)

Submission status: Runtime Error

Solution code:
n =int(input())
h = 1
m = 1000000000000000000
c = -1
for i in range(n):
    a = int(input())
    h *= a
if h > m :
    print(c)
else:
    print(h)

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 1
for _ in range(n):
    ans *= int(input())
if(ans > 1e18):
    ans = -1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
for _ in range(N):
  A = list(map(int,input().split()))
B = np.array(A)
V = np.prod(B)
if V<= 10**18:
  print(V)
elif V>10**18:
  print('-1')

Submission status: Runtime Error

Solution code:
a=int(input())
b=[]
c=1
for i in range(a):
  p=int(input())
  if(p==0):
    c=0
    break
  else:
  	c=c*p
if(c>1000000000000000000):
  print(-1)
else:
  print(c)

Submission status: Runtime Error

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

sum = num[0]

for i range(1,n):
  if len(str(sum)) > 16:
    sum = -1
    break
  sum = sum * num[i] 

print(sum)

Submission status: Runtime Error

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

list = [i for i in input().split()]

for a in range(N-1):
  ans = ans * i[a]

  if ans > 10**18:
    ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
prod=1
for i in range(0,n):
  u=int(input())
  prod=prod*u
 if(prod>1000000000000000000):
  print(-1)
 else:
  print(prod)

Submission status: Runtime Error

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

for num in A:
  ans = ans * num
  if num != 0:
    if ans / num != tmp:
      is_overflow = True

  if (num == 0):
    is_overflow = False
    ans = 0
    break

  tmp = ans

if (ans > 1e18 or ans < 0 or is_overflow): ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())

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

result = np.prod(a_list)
if result > 1 + e18:
    print(-1)
else:
    print(result)

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
while kotae<=10**18:
  for i in range(n+1):
    kotae=kotae*lista[i]
  print(kotae)
  break
print(-1)

Submission status: Runtime Error

Solution code:
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
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 IS(): return str(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")

N = II()
A = LI()
A_r = A[::-1]
ans = 1
ans_r = 1
flag  = False
if 0 in A:
    print(0)
else:
    if N%2 == 1:
        ans *= A[N/2]
    for i in range(0,N//2):
        ans *= A[i]
        ans_r *= A_r[i]


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

Submission status: Runtime Error

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

def func(n, a, i):
  if i == n:
    return 1
  return a[i] * func(n, a, i + 1)

res = func(n, a, 0)
if (res > 1000000000000000000):
  print('-1')
else:
  print(res)

Submission status: Runtime Error

Solution code:
import array


n = int(input())
a=[]
f=0
f1=0
b=0
for i in range(0,n):
    i = int(input())
    a.append(i)
    if i == 0:
        print("0");
        f1=1
        

sum =1
if f1==0:
    for i in a:
        sum=sum*i;
        if sum>1e18:
            f=1
            print("-1");
    
if f==0:
    print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(input().split())
ans = 1
lim = 18
Leng = ''.join(A)
flag = False

if Leng < lim:
    flag = True

for i in A:
    ans *= int(i)

if not flag and "0" not in A:
    print('-1')
else:
    print(ans)

# print(ans, lim)

Submission status: Runtime Error

Solution code:
N = int(input())#リストの要素数

#L = input().split()
#L = map(lambda x: int(x), L)
#ASW = functools.reduce(operator.mul, L)
L = list(map(int,input().split()))
ASW = functools.reduce(operator.mul, L)

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

Submission status: Runtime Error

Solution code:
N= int(input())
lists = list(map(int,input().split()))
#print(lists)
q=int(1)
for i in range(N):
    s = lists[i-1]
    q *= s
import math
#x =  np.power(10,18)
if math.log(q, 10)>=18:
    print(q)
else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from decimal import Decimal
K = int(input())
N = input().split()

ans = Decimal(str(N[0]))
for A in N[1:]:
    A = Decimal(str(A))
    ans = ans * A

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