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 decimal import *
N=int(input())
Al=list(map(Decimal,input().split()))
s=Decimal(1)
for i in range(N):
    s*=Al[i]


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

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__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = reduce(mul, A)
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)

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:
a = int(input())
b = input().split()

for i in range(a):
    if b[i] == 0:
        print(0)
        return

c = 1
for i in range(a):
    c = c*int(b[i])
    if c > 1000000000000000000:
        break

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

Submission status: Runtime Error

Solution code:
n = input()
a = input()
a = a.split()
x = 0;
mul = 1;

for num in a:
    if(int(num) == 0):
      mul = 0;
      break;
   
for num in a:
  mul *= int(num)
  if(mul > 1000000000000000000):
    mul = -1;
	break;
   
print(mul);

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=a[n])*(t=a[n+1])
    
n=n+1

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=input()
b=a.replace(' ', '*')
print(eval(b))
if b>=100000000000000000:
  print(-1)
else:
  print(b)

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__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = reduce(mul, A)
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)

Submission status: Runtime Error

Solution code:
n = input()
kakeru = 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:
n = int(input())
ans=int(1)
for i in range(n):
  tmp = int(input())
  ans= ans * tmp
if ans>1000000000000000000:
  print("-1")
else:
  print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x, y = input().split()
x = int(x)
y = int(y.replace(".", ""))
print((x*y)//100)

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__':
    N = int(input())
    A = map(int, input().split())
    ans = reduce(mul, A)
    if ans > 10 ** 18:
        print -1
        quit()
    print ans

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-1] 
    if b > 10 ** 18:
        b = -1
    return b
b = multi(b,l)
print(b)

Submission status: Runtime Error

Solution code:
m = int(input())
s = list(int(input().split()))
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=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    if(0 in a==True):
        print(0)
        exit()
    ans=ans*ch
    i+=1
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

int main(void) {
	long long N, A, result = 1;
	long long flag = 0, flag_zero = 0;
	
	scanf("%lld", &N);
	for (long long i = 0; i < N; i++) {
		scanf("%lld", &A);
		int cnt = 0;
		for (long long j = A; j > 1; j /= 10)cnt++;
		for (long long j = result; j > 1; j /= 10)cnt++;
		result = result * A;
		if (cnt > 18 || result > 1000000000000000000) {flag = 1;}
		if (A == 0) flag_zero = 1;
	}
	
	printf("%lld\n", flag_zero ? 0 : flag ? -1 : result);
	
	return 0;
}

Submission status: Runtime Error

Solution code:
t=int(input())
x=1;
i=0;
while i<t:
         a = int(input())
         x=x*a;

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

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__':
    N = int(input())
    A = map(int, input().split())
    ans = reduce(mul, A)
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)

Submission status: Runtime Error

Solution code:
from decimal import Decimal
N=int(input())
L=list(map(Decimal,input().split()))
L=np.prod(L)
 
if L>1000000000000000000:
    print("-1")
else:
    print(L)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input.split()))
a = sorted(a)
prod = 1
for x in a:
  prod *= x
  if prod > 10**18:
    prod = -1
    break
print(prod)

Submission status: Runtime Error

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

  
ans = 1
A.sort(reverse = True)
for i in range(len(A)):
  ans = ans * A[i] 
  if ans > lim:
    print(-1)
    exit()

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    if(0 in a==True):
        print(0)
        exit()
    ans=ans*calc[i]
    i+=1
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 2:
        for i in range(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:
from sys import stdin
input =stdin.readline
a=1
lst = [] 
n = int(input()) 
lst=list(map(int,input().strip().split()))
for i in lst:
    if(i==0)
    print(0)
    break
    a*=i;
    if(a>1000000000000000000)
    print(-1)
    break
print(a)

Submission status: Runtime Error

Solution code:
a = int(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)
elif aa <= 1000000000000000000:
    print(aa)

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
l = []
l1 = []
a = 1
if n < 200:
    for i in A:
        a = a * i
else:
    n0 = (n // 100) 
    for i in range(1, n0):
        l.append(i * 100)

    for i in l:
        x = A[0]
        for j in range(i*100-99, i*100):
            x = 1 * A[j]
        l1.append(x) 
    for i in l1:
        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 = list(map(int, input().split()))

for number in inlist:
  result = result * number

print(result)

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()
  
print(c)

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(int(ans))

Submission status: Runtime Error

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

total = 1

if li.index(0):
    total = 0
    print(total)
else:
    for a in li:
        total *= a
        if 10 ** 18 < total:
            total = -1
    print(total)

Submission status: Runtime Error

Solution code:
a = int(input())

if a == 2:
    aa = 1000000000 * 1000000000
elif a == 3:
    aa = 101 * 9901 * 999999000001
elif 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)
elif aa <= 1000000000000000000:
    print(aa)

Submission status: Runtime Error

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

ans=1
i=0
while ans<=10**18:
    ans*=a[i]
    i+=1
    
if ans>10**18:
    print("-1")
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
sum = 1
for (int i = 0; i < n; i++):
  sum = sum * int(input())
  
if (sum > 1000000000000000000):
  print("-1")
else:
  print(sum)

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

N = int(input())
int_numbers = [int(n) for n in input.split()]
  
if reduce(mul, int_numbers) > 10**18:
  print(-1)
else:
  print(reduce(mul, int_numbers))

Submission status: Runtime Error

Solution code:
N=int(input())
s=input().split()

if s[0]*s[1]>10**18:
    print(s[0]*s[1])
else:
    print("-1")

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

int main(void) {
	unsigned long long N, A, result = 1;
	unsigned long long flag = 0, flag_zero = 0;
	
	scanf("%lld", &N);
	for (unsigned long long i = 0; i < N; i++) {
		scanf("%lld", &A);
		int cnt = 0;
		for (long long j = A; j > 1; j /= 10)cnt++;
		for (long long j = result; j > 1; j /= 10)cnt++;
		result = result * A;
		if (cnt > 18 || result > 1000000000000000000) {flag = 1;}
		if (A == 0) flag_zero = 1;
	}
	
	printf("%lld\n", flag_zero ? 0 : flag ? -1 : result);
	
	return 0;
}

Submission status: Runtime Error

Solution code:
n=int(input())
arr=list(map(int,input().split())
pro=1
ans=True
for i in range(n):
	pro*=arr[i]
    if(pro>1000000000000000000 || pro<0):
    	ans=False
if(ans==False and pro!=0):
	print("-1")
else:
    print(pro)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from decimal import *
N=int(input())
Al=list(map(Decimal,input().split()))
s=Decimal(1)
for i in range(N):
    s*=Al[i]


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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from decimal import *
N=int(input())
Al=list(map(Decimal,input().split()))
s=Decimal(1)
for i in range(N):
    s*=Al[i]


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

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
l = []
l1 = []
a = 1
if n < 200:
    for i in A:
        a = a * i
else:
    n0 = (n // 100) 
    for i in range(1, n0):
        l.append(i * 100)

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

    for i in l1:
        a = a * i

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


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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**19)

N = int(input())
An_org = list(map(int, input().split()))
An = sorted(An_org)

def dfs(sum, i) :
    if i == len(An)-1 :
        return sum
   
    s = sum * An[i+1]

    if  s > 10 ** 18 :
        return -1

    return dfs(s, i+1)


print(dfs(An[0],0))

Submission status: Runtime Error

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

print(a)

Submission status: Runtime Error

Solution code:
a = int(input())

if a == 2:
    aa = 1000000000 * 1000000000
elif a == 3:
    aa = 101 * 9901 * 999999000001
elif 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:
a, b = input().split(" ")
print int(float(a) * int(b))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [int(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:
a=int(input())
b=list(map(int,input().split()))
c=1
for i in range(a):
	c=c*b[i]
    if(c>1000000000000000000):
      c=-1
      break
    elif(b[i]==0):
      c=0
      break
print(c)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
x=input.split()
prod=1
for i in x:
  prod=prod*i
  if prod>1000000000000000000:
    break
if prod>1000000000000000000:
  print(-1)
else:
  print(prod)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define pb push_back
#define mk make_pair

#define flu(i, s, e) for(int i = s; i < e; i++)
#define fld(i, s, e) for(int i = s; i >= e; i--)


int main(){
	fast;

	// freopen("input.txt", "r", stdin);
	// freopen("myoutput.txt", "w", stdout);

	int n; scanf("%d", &n);
	ll m, ans = 1;
	flu(i, 0, n){
		scanf("%lld", &m);
		ans *= m;
	}
	if(ans <= (ll)1e18 && ans >= (ll)0){
		
		printf("%lld\n", ans);
	}
	else{
		printf("-1\n");
	}

	return 0;
}

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [int(input()) for A 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 = input(int())
ans = 1
i = []
 
list = [i for i in input().split()]
 
for a in range(N):
  ans = ans * i[a]
 
  if ans > 10**18:
    ans = -1
 
print(str(ans))

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import numpy as np
n=int(input())
A=list(map(Decimal, input().split()))
a=Decimal(1)
for i in range(n):
    a=a*A[i]
if a > 10**18:
  print(-1)
else:
  print(a)

Submission status: Runtime Error

Solution code:

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

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

    int n;
    cin >> n;
    long long x = 1;
    long long res = 1;
    bool ok = true;
    while (n--) {
        long long a;
        cin >> a;
        if (a == 0) {
            cout << 0 << "\n";
            return 0;
        }
        if (!ok) continue;
        res *= a;
        if (res / a == x && res <= 1000000000000000000) {
            x = res;
        }
        else {
            ok = false;
        }
    }
    if (!ok) cout << -1 << "\n";
    else cout << res;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define pb push_back
#define mk make_pair

#define flu(i, s, e) for(int i = s; i < e; i++)
#define fld(i, s, e) for(int i = s; i >= e; i--)


int main(){
	fast;

	// freopen("input.txt", "r", stdin);
	// freopen("myoutput.txt", "w", stdout);

	int n; scanf("%d", &n);
	ll m, ans = 1;
	bool flag(0);
	flu(i, 0, n){
		scanf("%lld", &m);
		ans *= m;
	}
	if(ans <= (ll)1e18 && ans >= 0){
		
		printf("%lld\n", ans);
	}
	else{
		printf("-1\n");
	}

	return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

multi = 1
i = 0

if A[-1]==0:
    multi = 0

while A[-1] < 2:
    A.pop()
    i+=1

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

print(multi)

Submission status: Runtime Error

Solution code:
N = int(input()) 
A = list(map(int,input().split()))
c = 1
i = 0
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())
a=list(input().split())
ans=1
f=0
i=0
p=0
while(i<n):
    if f==0:
        if i==n-1:
            p=1
            ans=ans*int(a[i])
        else:
            ans=ans*int(a[i])*int(a[i+1])
    if f==0 and ans>1000000000000000000:
        f=1
    if int(a[i])==0:
        print(0)
        exit()
    if p==0:
        if int(a[i+1])==0:
            print(0)
            exit()
    i+=2
if f==1:
    print(-1)
    exit()
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**18)

N = int(input())
An_org = list(map(int, input().split()))
An = sorted(An_org)

def dfs(sum, i) :
    if i == len(An)-1 :
        return sum
   
    s = sum * An[i+1]

    if  s > 10 ** 18 :
        return -1

    return dfs(s, i+1)


print(dfs(An[0],0))

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
l = []
l1 = []
if n < 200:
    for i in A:
        a = a * i
else:
    n0 = (n // 100) 
    for i in range(1, n0):
        l.append(i * 100)

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

    for i in l1:
        a = a * i

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


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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

n=1

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
A = map(int,input().split())
 
ans = 1
for num in A:
	ans*=num
  if (ans > 10^18):
    ans = -1
    break

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from decimal import *
n=input()
ans=eval("Decimal("+input().replace(" ",")*Decimal(")+")")

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

Submission status: Runtime Error

Solution code:
N = int(input())
v = list(map(int, input().split()))
answer = reduce(lambda x,y: x*y, v)
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
T=int(input())
a=[]
result=1
for _ in range(T):
	a.append(int(input()))
for i in a:
	result=result*i
if result>pow(10,18):
	print(-1)
else:
	print(result)

Submission status: Runtime Error

Solution code:
import numpy as np

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
mul = 1
for i in li:
  j = int(i)
  mul *= j

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
from operator import mul
from functools import reduce

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

print(reduce(mul, i))
  
if reduce(mul,i) > 10 ** 18:
  print(-1)
else:
  print(educe(mul, i))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
a = [map(int,input().split)]
c = np.prod(a)
print(c)

Submission status: Runtime Error

Solution code:
def multiply( array , n ): 
	pro = 1
	for i in range(n): 
		pro = pro * array[i]
	return pro 

array = []

n = int(input())
for i in range(0, n):
	ele = int(input())
	array.append(ele)

a = multiply(array,n)
if a > 1e18:
	print(-1)
else:
	print(a)

Submission status: Runtime Error

Solution code:
m = int(input())
s = input().split()
for i in s:
    n.append(int(i))
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:
N = int(input())
list=[]
for i in range(N):
  list.append(int(input()))

s = 1
for l in list:
  s = s * l

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
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:
def resolve():
    N = int(input())
    list = list(map(int, input().split()))
    no = 0
    non = 0
    ans = 1
    lens = 0
    if (list.count("0") >= 1):
      print("0")
      exit()
    else:
      for i in range(N):
        lens = lens + len(list[non])
        non += 1
    if (lens >= 19):
      print("-1")
      exit()
    else:
      for j in range(N):
        ans = ans * list[no]
        no += 1
        print(ans)
resolve()

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+1:
        print("-1")
    elif a>=c**2+1:
        a=a-c
        count=count+1
    
if count>=2:
    print("-1")
elif count=1:
    print(a*c)
else:
    print(a)

Submission status: Runtime Error

Solution code:
n = int(input())
  
ans = 1
for i in range(0, n): 
    ele = long(input()) 
    if ans * ele > 1000000000000000000:
        ans = -1
    elif ans != -1:
        ans = ans * ele
      
print(ans)

Submission status: Runtime Error

Solution code:
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,i(n-1)//2+1):
			ans=ans*a[i]*a[i+(n-1)//2]

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

Submission status: Runtime Error

Solution code:
n = int(input())
lst1 = []
lst1 = [int(item) for item in input().split()]
ans = 1
for num in lst1:
	if num == 0:
		flag=1
		print(0)
if flag == 0:
	for num in lst1:
		ans *= num
	if ans > 1000000000000000000:
		print(-1)
	else:
		print(ans)

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  sys.exit()
else:
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:
import math
from decimal import Decimal
N = int(input())
A_list = list(map(str,input().split()))
B_list = []

if '0' in A_list:
  print('0')
  
else:
  for i in range(N):
    logA = Decimal(A_list[i]).log10()
    B_list.append(logA)
 
sum = 0
pro = 1
for j in range(N):
  sum += B_list[j]

if sum > 18:
  print('-1')
else:
  for k in range(N):
    pro *=Decimal(A_list[k])
  print(pro)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	cin >> N;
	vector<long long> A( N );
	long long ans = 1;
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
		if( A[i] == 0 ) {
			ans = 0;
			break;
		}
	}
	if( ans == 1 ) {
		double l = 0;
		for( int i = 0; i < N; i++ ) {
			l += log10( (double)A[i] );
		}
		if( l > 18 ) {
			ans = -1;
		}
		else {
			for( int i = 0; i < N; i++ ) {
				ans *= A[i];
				if( ans > 1000000000000000000 ) {
					ans = -1;
					break;
				}
			}
		}
	}
 
	cout << ans << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
a = []
int seki = 1
for c in kita:
    a.append(c)
try:
    for c in a:
        c = c * int(c)
    if c > 10**18:
        print("-1")
    else:
        print(c)
except:
    print("-1")

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

multi = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        multi = 0
        break

for i in range(n):
    if a == 0:
        break

    multi *= n_list[i]

    if multi>1e18:
        break

print(multi)
if multi<=1e18:
    print(multi)
else:
    print(-1)

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:
n = int(input())
  
ans = 1
for i in range(0, n): 
    ele = int(input()) 
    ans = ans * ele
    if ans > 1000000000000000000:
        ans = -1
      
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())

if a == 2:
    aa = 1000000000 * 1000000000
elif a == 3:
    aa = 101 * 9901 * 999999000001
elif 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:
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:
N=int(input())
ans=eval(input().replace(" ","*"))
print(ans if ans<=10**18 else "-1")

Submission status: Runtime Error

Solution code:
N = input(int())
ans = 1
i = []
a = int()
 
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 = int(input()) 
A = list(map(int,input().split()))
c = 1
i = 0
for i in N-1:
  c *= A[i]
   if c >= 10**18:
      print(-1)
  
print(c)

Submission status: Runtime Error

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

Submission status: Runtime Error

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