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:
from operator import mul
from functools import reduce
import numpy as np

if __name__ == '__main__':
    try:

        N = int(input())
        A = np,array(list(map(int, input().split())))
        ans = reduce(mul, A)
        if ans > 10 ** 18:
            print(-1)
        else:
            print(ans)
    except:
        if 0 in A:
            print(0)
        else:
            print(-1

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int n;

long long res = 1, t;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> t;
		res *= t;
		cout << res;
	}
	cout.tie(0);
	if (res > 1000000000000000000) cout << -1;
	else cout << res;
}

Submission status: Runtime Error

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

from operator import mul
result = reduce(mul, l)

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

Submission status: Runtime Error

Solution code:
    import numpy as np
    from operator import mul
    from functools import reduce
    N = int(input().strip())
    A = list(map(int,input().split()))
    x = reduce(mul, A)
    if x > 1000000000000000000:
        print("-1")
    else:
        print(x)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [input() for i 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())
sum=1
f=0
f2=0
for i in range(0,n):
	a=int(input())
	if  (a==0): 
		f2=1
	sum=sum*a
	if (sum>1000000000000000000):
		f=1;
}
if (f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Submission status: Runtime Error

Solution code:
N = int(input())

l = list(map(int, input().split()))
x = 1

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

print(x)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
import math
ans =1
ord =0
m = 1
 
if min(A) == 0:
    print(0)
else:
    for i in range(N):
        ord += math.log10(A[i])
        m = m*A[i] % 10
    if ord >= 18 and m > 0:
        print(-1)
    else:
        print(int(10**ord))

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
l = []
m = []
a = 1
x = A[0]

if n < 200:
    for i in A:
        a = a * i
else:
    p = n // 100
    for i in range(1, p):
        l.append(i * 100)

    for i in l:
        b = i*100-99
        c = i*100
        for j in range(b, c):
            x = x * A[j]
        m.append(x) 

    for i in m:
        a = a * i

    if n % 100 != 0:
        d = n % 100 + 1
        for i in range (1, d):
            k = -1 * i
            a = a * A[k]


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

Submission status: Runtime Error

Solution code:
import math
a,b=map(str,input().split())
a=int(a)
b=float(b)

#x=int(a*b)
x=math.floor(a*b)
print(x)

Submission status: Runtime Error

Solution code:
a=input()
b=eval(input().replace(" ","*"))
print(-1 if b>10**18 else b)

Submission status: Runtime Error

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

a= list(map(float,input().split()))
def calc_double(n):
    return n / 10
a2 = list(map(calc_double,a))
#print(a2)

ans=np.prod(a2)*10**n

if ans>10**(18) or ans<0:
    ans=-1
print(int(ans))

Submission status: Runtime Error

Solution code:
#B
from functools import reduce

n = int(input())
a = list(map(int,input().split()))
flg = True
MAX = 10 ** 18
cnt = 1
a.sort()
result = reduce(lambda ans, x:ans * x, a)
if result > MAX:
    flg = False
    break
        
if flg:
    print(result)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
n=input()
sum=1
f=0
f2=0
for i in range(0,n):
	a=input()
	if  (a==0): 
		f2=1
	sum=sum*a
	if (sum>1000000000000000000):
		f=1;
}
if (f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Submission status: Runtime Error

Solution code:
from decimal import Decimal
N=Decimal(input())
L=list(map(Decimal,input().split()))
M=1
if max(L)>1000000000000000000:
    print("-1")
else:
    for i in L:
        M=M*i
    if M>1000000000000000000:
        print("-1")
    else:
        print(M)

Submission status: Runtime Error

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

if an[0] >= 10**18:
    print(-1)
else:
    print(an[0])

Submission status: Runtime Error

Solution code:
n = int(input())  #nは入力回数
num_list = [int(input()) for _ in range(n)]

ans = 0
ok = 0
for i in range(n):
    ans *= num_list[i]
    if ans > 1000000000000000000:
        ok = 1

if ok == 1:
    print(-1)
else
    print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;
  cin >> n;
  
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v.at(i);
    if (v.at(i) == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (v.at(i) >= 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
  } 
  long long ans = 1;
  for (long long i = 0; i < n; i++) {
    ans *= v.at(i);
    if (ans > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
import math
ans =1
ord =0
m = 1
 
if min(A) == 0:
    print(0)
else:
    for i in range(N):
        ord += math.log10(A[i])
        m = m*A[i] % 10
    if ord >= 18 and m > 0:
        print(-1)
    else:
        print(10**ord)

Submission status: Runtime Error

Solution code:
listed = input().split()
mul = 1
maxi = 10**18
for num in listed:
  mul*=num
  if num == 0:
    print(mul)
  if num > maxi**18:
    print(mul)
print(mul)

Submission status: Runtime Error

Solution code:
n=input()
sum=1
f=0
f2=0
for i in range(0,n):
	a=input()
	if  (a==0): 
		f2=1
	sum*=a
	if (sum>1000000000000000000):
		f=1;
}
if (f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Submission status: Runtime Error

Solution code:
n = long(raw_input())
a = 1L
for i in range(0, n):
	ele = long(raw_input())
	a = a * ele
	if a > 1e18:
		print(-1)

print(a)

Submission status: Runtime Error

Solution code:
#B
from functools import reduce
n = int(input())
a = tuple(map(int,input().split()))
flg = True
MAX = 10 ** 18
cnt = 1
a.sort()
result = reduce(lambda ans, x:ans * x, a)
if result > MAX:
    flg = False
    break
        
if flg:
    print(result)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
n= int(input())
a= list(map(int,input().split()))
 
ans = 1
over = -1
 
if 0 in a:
    print(0)
    exit(0)

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

print(ans)

Submission status: Runtime Error

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

result = reduce(lambda x,y: x*y, l)

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

Submission status: Runtime Error

Solution code:
n = int(input())
frag = 10**9
a = list(map(float, input().split()))

for i in range(n):
  a[i] = a[i]/float(frag)
  
ans = 1

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

for i in range(n):  
	ans = ans * float(frag)
    
    
if(ans > 10**18):
    ans = -1

print(int(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
list = list(map(int, input().split()))
no = 0 
ans = 1
c = 0
if list.count("0") >0:
  print("0")
  exit()
else:
  for i in range(N):
    ans = ans * list[no]
    c = c + len(str(list[no]))
    no += 1
    if lens >= 19:
      exit()
    else:
      continue
print(ans)

Submission status: Runtime Error

Solution code:
n=input()
sum=1
f=0
f2=0
for i in range(1,n):
	a=input()
	if (a==0): 
		f2=1
	sum*=a
	if (sum>1000000000000000000):
		f=1;
}
if(f2==1): 
	print("0\n")
else if(f==1):
	print("-1\n")
else:
	print(sum)
	print("\n")

Submission status: Runtime Error

Solution code:
N=int(input())
from decimal import Decimal
P=input().split()
for i in range(0,len(P)):
    P[i]=Decimal(P[i])
import numpy
Q=numpy.array(P)

result =numpy.prod(Q)

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

Submission status: Runtime Error

Solution code:
n = input()
nn = int(n)
x = 1
for i in range(nn):
    a = input()
    aa = int(a)
    x *= aa
    print(x)
if x > pow(10, 18):
    print("-1")

Submission status: Runtime Error

Solution code:
from functools import reduce 
n=int(input())
l=map(int,input().split(' '))
if 0 in l:
    result1=0;
else:
    result1 = reduce((lambda x, y: x * y), l)
if result1>10**18:
    print("-1")
else:
    print(result1)

Submission status: Runtime Error

Solution code:
N = int(input())
list = list(map(int, input().split()))
no = 0 
ans = 1
lens = 0
if list.count("0") >0:
  print("0")
  exit()
else:
  for i in range(N):
    ans = ans * list[no]
    lens = lens + len(list[no])
    no += 1
    if lens >= 19:
      exit()
    else:
      continue
print(ans)

Submission status: Runtime Error

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

n=0

for n <= N
    T=a[n]
T*=T=a[n]
    
n=n+1

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

Submission status: Runtime Error

Solution code:
import numpy as np
from decimal import *
N=int(input())
Al=list(map(float,input().split()))

Al=np.array(Al)

c=Al.prod()

if c>1000000000000000000:
    print(-1)
else:
    print(int(c))

Submission status: Runtime Error

Solution code:
from functools import reduce
from operator import mul

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

A.remove(1)

ans = reduce(mul, A)

if ans <= 1000000000000000000:
    print(ans)
    exit()

print(-1)

Submission status: Runtime Error

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

result = reduce(lambda x,y: x*y, l)

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

Submission status: Runtime Error

Solution code:
n= int(input())
a= list(map(int,input().split()))
 
ans = 1
 
if 0 in a:
    print(0)
    exit(0)

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

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())  #nは入力回数
num_list = [int(input()) for _ in range(n)]

ans = 0
ok = false
for i in range(n):
    ans *= num_list[i]
    if ans > 1000000000000000000:
        ok = true

if ok:
    print(-1)
else
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
l=list(map(int,input().strip().split()))[:n]
product=1
flag=0
flagp=0
for i in range(n):
  if l[i]==0:
    flag=1
  if product>1000000000000000000:
    flagp=1
  else:
    p*=l[i]
if flag:
  print(0)
elif flagp:
  print(-1)
else:
  print(p)

Submission status: Runtime Error

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

for i in range(n):
  a[i] = a[i]/float(frag)
  
ans = 1

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

for i in range(n):  
	ans = ans * float(frag)
    
    
if(ans > 10**18):
    ans = -1

print(int(ans))

Submission status: Runtime Error

Solution code:
ースコード 

Copy
Copy
N = int(input())
s = list(map(int,input().split()))
t = 1
 
for i in range (N):
    t = t * s[i]
 
if( t <= 10**18):
    print(t)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
from functools import reduce 
n=int(input())
l=map(int,input().split(' '))
if 0 in l:
    result1=0;
else:
    result1 = reduce((lambda x, y: x * y), l)
if result1>10**18:
    print("-1")
else:
    print(result1)

Submission status: Runtime Error

Solution code:
n=(input())
		a=0
		sum=1
		f=0
		f2=0
		for i in range(1,n):
			a=(input())
			if(a==0): 
				f2=1
			sum*=a
			if (sum>1000000000000000000):
				f=1;
		}
		if(f2==1): 
			print("0\n")
		else if(f==1):
			print("-1\n")
		else:
			print(sum)
			print("\n")

Submission status: Runtime Error

Solution code:
n = input()
c = 0;
for(i in range(n)) :
  x = input()
  c *= x;
print(c)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [input().split() for i in range(N+1)]
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())  #nは入力回数
num_list = [int(input()) for _ in range(n)]

ans = 0
ok = false
for i in range(n):
    ans *= num_list[i]
    if(ans > 1000000000000000000):
        ok = true
        break

if(ok):
    print(-1)
else
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
a = 1L
for i in range(0, n):
	ele = int(raw_input())
	a = a * ele
	if a > 1e18:
		print(-1)

print(a)

Submission status: Runtime Error

Solution code:
def mult(m):
  s = 1
  for x in m:
    s = s*x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input().split()))
a.sort()
z = mult(a)
print(z)

Submission status: Runtime Error

Solution code:
n = input()
kakeru = map(int,input().split())
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i-1]
    elif n==2:
    kakekake = kakeru[0] * kakeru[1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [input(i).split() for i 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=ll(input())
		a=0
		sum=1
		f=0
		f2=0
		for i in range(1,n):
			a=ll(input())
			if(a==0): 
				f2=1
			sum*=a
			if (sum>1000000000000000000):
				f=1;
		}
		if(f2==1): 
			print("0\n")
		else if(f==1):
			print("-1\n")
		else:
			print(sum)
			print("\n")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())  #nは入力回数
num_list = [int(input()) for _ in range(n)]

ans = 0
ok = false
for x in num_list
    ans *= x
    if(ans > 1000000000000000000):
        ok = true
        break

if(ok):
    print(-1)
else
    print(ans)

Submission status: Runtime Error

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

result = reduce(lambda x,y : x*y, l)

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

Submission status: Runtime Error

Solution code:
#include<stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define cnt 1000000000000000000
int main(){
  int N;
  long int A[1000000];
  long long int sum=1;
  scanf("%d", &N);
  for (int i = 0; i <N; i++){
    scanf("%ld",&A[i]);
    sum *= A[i];

  }

  
  if(sum >cnt){
    printf("-1\n");
  }else{
    printf("%lld\n", sum);
  }
  return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
l = []
m = []
a = 1
x = A[0]

if n < 200:
    for i in A:
        a = a * i
else:
    p = n // 100
    for i in range(1, p):
        l.append(i * 100)

    for i in l:
        b = i*100-99
        c = i*100
        for j in range(b, c):
            x = x * A[j]
        m.append(x) 

    for i in m:
        a = a * i

    if n % 200 != 0:
        d = n % 100 + 1
        for i in range (1, d):
            k = -1 * i
            a = a * A[k]


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

Submission status: Runtime Error

Solution code:
n = input()
a = 1L
for i in range(0, n):
	ele = input()
	a = a * ele
	if a > 1e18:
		print(-1)

print(a)

Submission status: Runtime Error

Solution code:
import math
d,f = map(float,input.split())
print(round(d*f))

Submission status: Runtime Error

Solution code:
N=int(input())
from decimal import Decimal
P=input().split()
for i in range(0,len(P)):
    P[i]=Decimal(P[i])
import numpy
P=numpy.array(P)

result =numpy.prod(P)
 
if result>pow(10, 18):
    print(-1)
else:
    print(result)

Submission status: Runtime Error

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

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(int, sys.stdin.readline().split()))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
a,b = input().split()
n = b.find('.')
if n > 0:
  bi = int(b[:n])
  bf = int(b[n+1:])
else:
  bi,bf = int(b),0
  
ans = str(math.floor(int(a)*(bi*100+bf)))
N = ans.find('.')
if N > 0:
  ai = int(ans[:n-2])
else:
  ai = int(int(ans)/100)
print(ai)

Submission status: Runtime Error

Solution code:
n = int(input())  #nは入力回数
num_list = [int(input()) for _ in range(n)]

ans = 0
ok = false
for x : num_list
    ans *= x
    if(ans > 1000000000000000000):
        ok = true
        break

if(ok):
    print(-1)
else
    print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np;
from numba import jit
import warnings
from operator import mul
from functools import reduce
warnings.simplefilter('ignore')
    

if __name__ == '__main__':
    try:

        N = int(input())
        A = list(map(int, input().split()))
        ans = reduce(mul, A)
        if ans > 10 ** 18:
            print(-1)
        else:
            print(ans)
    except:
        if 0 in A:
            print(0)
        else:
            print(-1

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
import math
a,b = input().split()
n = b.find('.')
if n > 0:
  bi = int(b[:n])
  bf = int(b[n+1:])
else:
  bi,bf = int(b),0
  
ans = str(math.floor(int(a)*(bi*100+bf)))
N = ans.find('.')
if N > 0:
  ai = int(ans[:n-2])
else:
  ai = int(ans/100)
print(ai)

Submission status: Runtime Error

Solution code:
n = int(input())  #nは入力回数
num_list = [int(input()) for _ in range(n)]
print(num_list) 

ans = 0
bool ok = false
for x : num_list
    ans *= x
    if(ans > 1000000000000000000):
        ok = true
        break

if(ok):
    print(-1)
else
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())  #nは入力回数
num_list = [int(input()) for _ in range(n)]
print(num_list) 

ans = 0
bool ok = false
for x : num_list
    ans *= x
    if(ans > 1000000000000000000):
        ok = true
        break;

if(ok):
    print(-1)
else
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(raw_input()) 
arr = [int(x) for x in raw_input().split()] 
prod = 1
for x in arr:
    prod = prod*x
if(prod>1000000000000000000):
    print("-1")
else:
    print(prod)

Submission status: Runtime Error

Solution code:
x = int(input())
ans = 1
for i in range(x):
    y = int(input())
    ans = ans * y

if(ans>1000000000000000000):
    ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
values =list(map(int, input().split()))
a=1
 
for i in range(n):
  a=a*values[i]
  
import math
if math.log10(a) < 18:
  print(a)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [int(input().split()) for i 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:
import numpy as np
from decimal import *
N=int(input())
Al=list(map(Decimal,input().split()))

Al=np.array(Al)

c=Al.prod()

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

Submission status: Runtime Error

Solution code:
num1 = int(input())
num2 = float(input())
mul = round(num1 * num2)
print(mul)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
l = np.array(list(map(int, input().split())))
b = 1
def multi(n,b,l):
    for i in range(n):
        b = b * l[i] 
    if b > 10 ** 18:
        b = -1
    b = int(b)
    return b
b = multi(b,l)
print(b)

Submission status: Runtime Error

Solution code:
num = int(input())
str2 = input().split(" ")
nums = [int(s) for s in str2]
nums.sort()

for i in range(len(nums)):
    ans = ans * nums[i]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
print(ans)
quit()

Submission status: Runtime Error

Solution code:
def mult(m):
  s = 1
  for x in m:
    s = s*x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input.split()))
a.sort()
z = mult(a)
print(z)

Submission status: Runtime Error

Solution code:
N = int(input())

l = list(map(int, input().split())
x = 1
for i in l:
	x *= i
if x <= 10**18:
	print(x)
else:
    print(-1)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
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:
A,B = map(float,input().split())
B = B*100
print(int(A*B/100))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
l = np.array(list(map(int, input().split())))
b = 1
def multi(n,b,l):
    for i in range(n):
        b = b * l[i] 
    if b > 10 ** 18:
        b = -1
    return b
b = int(multi(b,l))
print(b)

Submission status: Runtime Error

Solution code:
n = input()
x = 1
for i in range(n):
    a = input()
    x *= a
    print(x)
if x > pow(10, 18):
    print("-1")

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(int, input().split()))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def mult(m):
  s = 1
  for x in m:
    s = s * x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input().split()))
a.sort()
z = mult(m)
print(z)

Submission status: Runtime Error

Solution code:
s = "*".join(N)
ans = eval(s)
if ans <= 10**18:
    print(ans)
else:
    print('-1')

Submission status: Runtime Error

Solution code:
n= int(input())
a = list(map(int,input().split()))
ans = a[0]
ans_max = 10 ** 18

for i in range(1, n):
    ans *= a[i]
    if ans > ans_max:
        print("-1")
        sys.exit()

print(ans)

Submission status: Runtime Error

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

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

lst = [] 
  
# number of elemetns as input 
n = int(input()) 
flag = 0
  # iterating till the range 
for i in range(0, n): 
    ele = int(input()) 
  	if(ele == 0)
    	flag = 1
    lst.append(ele) # adding the element 
if(flag == 1)
	print("0")
else
	p = multiplyList(lst)
    if(p > 1000000000000000000)
    	print("-1")
    else
    	print(p);

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [map(int, input().split()) for i 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:
import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(operator.mul.v)
answer = answer if answer <= 10 ** 18 else -1
print(answer)

Submission status: Runtime Error

Solution code:
    import numpy
     
    N = int(input())
    A = int(input().split())
     
    B = numpy.prod(A)
     
    if B >= 10**18:
      print(-1)
    else:
      print(B)

Submission status: Runtime Error

Solution code:
n = input()
x = 1
for i in range(n):
    a = input()
    x *= a
if x > pow(10, 18):
    print("-1")

Submission status: Runtime Error

Solution code:
b= int(input())
a= list(map(int,input().split()))
res = 1
found =False
for i in a:
  res=res*i
  if(res>100000000000000000):
    found=True
    break;
if(!found):
  print(res)
else:
  print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(mul.v)
answer = answer if answer <= 10 ** 18 else -1
print(answer)

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
  elif 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:
numIntegers = input()
total = 1
line = input().split(" ")

for x in line:
    total *= x

if total > 1000000000000000000:
    print(-1)

else:
    print(total)

Submission status: Runtime Error

Solution code:
import numpy as np
from decimal import Decimal

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

A = np.array(a)
a_mul = Decimal(int(np.prod(A)))

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

Submission status: Runtime Error

Solution code:
from decimal import Decimal
N = int(input())
A = list(map(str, input().split()))
res = 1
for i in range(N):
    res = Decimal(str(res)) * Decimal(A[i])
if res > (10 ** 18):
    print(-1)
    exit()
print(res)

Submission status: Runtime Error

Solution code:
import functools
import operator

N = int(input())

l = list(map(int, input().split())
result = functools.reduce(operator.mul, li)

print(result)

Submission status: Runtime Error

Solution code:
a = input()

if a == "2":
    aa = 1000000000 * 1000000000

if a =="3":
    aa = 101 * 9901 * 999999000001

if a == "31":
    aa = 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

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

Submission status: Runtime Error

Solution code:
def mult(m):
  s = 1
  for x in m:
    s = s*x
    if s == 0:
      return 0
    if s > 10**18:
      return -1
   return s
n = int(input())
a = list(map(int,input.split()))
a.sort()
z = mult(m)
print(z)

Submission status: Runtime Error

Solution code:
n = input()
a = 1
for i in range(0, n):
	ele = input()
	a = a * ele
	if a > 1e18:
		print(-1)

print(a)

Submission status: Runtime Error

Solution code:
from decimal import *
import numpy as np
n=input()
ans=list(map(Decimal,input().split()))
ans = np.prod(ans)

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

Submission status: Runtime Error

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

n=1

for n <= (N-1)
    T=a[n]
T=T*(t=a[n+1])
    
n=n+1

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

Submission status: Runtime Error

Solution code:
import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(mul.v)
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

Submission status: Runtime Error

Solution code:
N=int(input())
if N>=2 and N<=10**5:
    array = list(map(int, input().strip().split()))
    if N==len(array):
        if array[0]>=0 and array[-1]<=10**18:
            mul=1
            for i in array:
                mul*=array[i-1]
            if mul>=10**18:
               print(-1)
            else:
                print(mul)

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
l = []
m = []
a = 1
x = A[0]

if n < 200:
    for i in A:
        a = a * i
else:
    p = n // 100
    for i in range(1, p):
        l.append(i * 100)

    for i in l:
        for j in range(i*100-99, i*100):
            x = x * A[j]
        m.append(x) 

    for i in m:
        a = a * i

    if n % 200 != 0:
        for i in range (1, n % 100):
            a = a * A[-1 * i]


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

Submission status: Runtime Error

Solution code:
n = int(input())
a = 1
for i in range(0, n):
	ele = input()
	a = a * ele
	if a > 1e18:
		print(-1)

print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import operator
import functools
from decimal import Decimal
n=int(input())
A=list(map(Decimal, input().split()))
Π = functools.partial(functools.reduce, operator.mul)
a=Π(A)
if a <= 10**18:
    print(a)
else:
    print(-1)