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:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  =  vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    int n;
    cin >> n;

    int ans = 1;
    bool flag = false;
    bool zero = false;
    rep(i, n){
        int a;
        cin >> a;
        if(a > (ll)(1e18) / ans){
            flag = true;
        } 
        if(a == 0){
            zero = true;
        }
        ans *= a;
    }
    
    if(flag && !zero){
        cout << -1 << endl;
    }
    else if(zero){
        cout << 0 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
l=[]
a = 1
for i in range(n):
  s = int(input())
  a = a*s
  if a ==0:
    break
  if a >= 10**18:
    a == -1
    break
print(a)

Submission status: Runtime Error

Solution code:
import math
a,b = map(float,input().split())
b = math.floor(b*100+0.4)
ans = (a*b)/100
print(math.floor(ans))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
import math
b = [math.log10(i) for i in a]    
if sum(b)>18:
    print(-1)
else:
    z = 1
    for i in a:
        z*=i
    if z>10**18:
        print(-1)
    else:
        print(z)

Submission status: Runtime Error

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

Submission status: Runtime Error

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


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

if '0' in i:
    print(0)
    return

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in ans:
    ans *= i

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

Submission status: Runtime Error

Solution code:
n=int(input())
lis=list(map(int,input().split()))
count=1
if 0 in lis:
  print(0)
  exit()
for num in lis:
    count *= num
	if count > 10**18:
    	print(-1)
        exit()
print(count)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import numpy as np
 
n=int(input())
i = list(map(int, input().split()))
ans = np.prod(i)
 
if ans.1e18:
  ans=-1
print(ans)

Submission status: Runtime Error

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

ans=1
for i in range(N):
    ans *= A[i]
    if ans > int(1e18):
        break
if result > 10 ** 18:
  print(-1)
else:
  print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b=map(str,input().split())
b1=int(b*100)
a1=int(a)
ans=int(a1*b1/100)
print(int(ans))

Submission status: Runtime Error

Solution code:
def m(list1,n): 
    mul=1
    for i in range(n): 
         mul=mul*list1[i] 
    return mul 
      
n=int(input())
arr=list(map(int,input().split()))
if m(arr)>pow(10,18):
    print(-1)
else:
    print(m(arr))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from decimal import Decimal
a,b=map(float, input().split())
print(int(Decimal(a)*Decimal(b)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,*a=map(int,open(0).read().split())
s=1
if any(a==0):
  print(0)
  exit()
for i in a:
  s*=i
  if s>1e18:
    print(-1)
    exit()
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from decimal import Decimal
a, b = input().split()
a = Decimal(int(a))
b = Decimal(b)
print(int(a * b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
num = int(input())
nums = list(map(int,input().split()))
ans = 1
for i in range(num):
    if nums[i] == 0:
        ans = 0
if ans != 0:
    for j in nums:
        ans *= nums[j]
        if len(str(ans)) > 18:
            ans = -1
            break
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(N):
    b = b * a[i]
    if b > 10 ** 18:
      b = 'out'

if b == 'out':
  print(-1)
else:
  print(b)

Submission status: Runtime Error

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

A.sort()
A.reverse()

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


if(flag != 1):
    print(ans)
else :
    print(-1)

Submission status: Runtime Error

Solution code:
import math
A, B = input().split()

print(math.floor(int(A)*float(B)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
lis=list(map(int,input().split()))
ans=1
for i in lis:
    ans*=i
    if ans>1000000000000000000:
    ans=-1
    break
else:
    print(ans)

Submission status: Runtime Error

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

from decimal import decimal

a, b = input().split()

print(int(decimal(a)*decimal(b)))

Submission status: Runtime Error

Solution code:
import math as m
a,b=list(map(float,input().split()))
print(m.floor(a*(b*10**5)/10**5))

Submission status: Runtime Error

Solution code:
#B failu
a=int(input())
b=list(map(int,input().split()))

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

Submission status: Runtime Error

Solution code:
from decimal import Decimal as dc
a,b = input().split()
print(int(dc(a)*dc(b)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
// Take care of mod becoming -ve


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define fro(i,s,e) for(auto i=s;i<=e;++i)
#define int long long
#define ld long double
#define fr(i,n) for(auto i=0;i<(int)n;i++)
#define ff first
#define pf pop_front()
#define ss second
#define mp make_pair
#define vi std::vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrbits(x) __builtin_ctzll(x)
#define vii std::vector<int,int>
#define tc int t;cin>>t;while(t--)
#define FILE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inp(a) long long a;cin>>a;
#define ps(x,y) fixed<<setprecision(y)<<x
#define mkarr(arr,n,type) type *arr=new type[n];
#define endl "\n"
#define sz size()
#define rev(i,e,s) for(auto i=e;i>=s;--i)
const int mod = 1000000007;
#define min_pq priority_queue<int,std::vector<int>,greater<int>>
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
const int MAXN = 100005;
const int inf = 1e18;
#define fill(s,x) memset(s,x,sizeof(s));
inline int add(int a, int b) {return ((a % mod + b % mod) % mod);}
inline int sub(int a, int b) {return ((a % mod - b % mod) % mod);}
inline int mult(int a, int b) {return ((a % mod) * (b % mod)) % mod;}
#define pi 3.14159265358979323846264338327950
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
// Use __gcd(a,b) for gcd
// find(all(x),key) to get the iterator and its index is obtained by find(all(x),key)-x.begin()
// find_if(iterator_first,iterator_last,unary function) returns first iterator if any element corresponding to unary function exists and if no such element is found it retrurns the last iterator
/*For example:
find_if(all(x),isodd) for x being a vector{10,25,40,55}; *it returns 25*/
/*search(all(v1),all(v2),pred) searches for all the elements of v2 present in v1 based on pred function the iterator correspond
to the first element of sequence if it exists and if not then th elast iterator is obtained.*/
//use substr(size_t pos,size_t len) for the substrings
int binsearch(int* a, int start, int end, int key) {
	while (start <= end) {
		int mid = start + (end - start) / 2;
		if (a[mid] < key)
			start = mid + 1;
		else if (a[mid] > key)
			end = mid - 1;
		else
			return mid;
	}
	return -1;
}
int power(int a, int b) {
	long long ans = 1;
	while (b > 0) {
		if (b & 1LL) {ans = (ans * a) % mod;}
		a = (a * a) % mod;
		b = (b >> 1LL);
	}
	return ans;
}
int32_t main() {
	fio;
	// indexed_set s;
	// s.insert(2);
	// auto y = s.find_by_order(7);
	// cout << *x << " " << *y <<
	int n;
    cin>>n;
    vi a;
    a.resize(n);
    fr(i,n){
        cin>>a[i];
    }
    if(count(all(a),0)){
        cout<<0<<endl;
        return 0;
    }
    int ans(1);
    fr(i,n){
        if(ans>(int)3e18/a[i]){
            cout<<-1<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout<<(ans>(int)1e18?-1:ans)<<"\n";
	printclock;
	return 0;
}

Submission status: Runtime Error

Solution code:
num = int(input())
nums = list(map(int,input().split()))
ans = 1
for i in range(num):
    if nums[i] == 0:
        ans = 0
if ans != 0:
    for j in nums:
        ans += nums[j]
        if len(str(ans)) > 18:
            ans = -1
            break
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy
import math
import sys

def main():
    n = int(input())
    a = sorted(input_list())
    max_n = 10 ** 18
    ans = 1
    for v in a:
        ans *= v
        if ans > max_n:
            ans = -1
            break
        if ans == 0:
            break
    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:
N = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(N):
    b *= a[i]
    if b > 10 ** 18:
      b = 'out'

if b == 'out':
  print(-1)
else:
  print(b)

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
sum=1
f=0
f2=0
if 0 in a:
        f2=1
for a in A:
	sum=sum*a
	if (sum>10**18):
		sum=-1
                break
if f2==1: 
	print(0)
else:
	print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())
a = 1
L = list(map(int, input().split()))
for i in L:
    a *= i
    if(a > 1e18)break

print(-1 if a > 1e18 else a)

Submission status: Runtime Error

Solution code:
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int,input().split()))
# limit=10**18

# if 0 in a:
#     print(0)
#     exit()

ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(n):
  ans *= a[i]
  if sum > 10 ** 18:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

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

# if ans > limit:
#   print(-1)
# else:
print(ans)

Submission status: Runtime Error

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

typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef long double ld;

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

int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout << (ll)ans;
return 0;
}

Submission status: Runtime Error

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

A.sort()
A.reverse()

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


if(flag != 1):
    print(ans)
else :
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import numpy as np
from decimal import Decimal
n = int(input()) 
A = list(map(Decimal, input().split()))
i = 10 ** 18
ans = int(np.prod(A))
if ans > i:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int,input().split()))
limit=10**18

# if 0 in a:
#     print(0)
#     exit()

ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(a):
  ans *= a[i]
  if sum> limit:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

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

# if ans > limit:
#   print(-1)
# else:
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def main():
    n = int(input())
    a = sorted(input_list())
    max_n = 10 ** 18
    ans = 1
    for v in a:
        ans *= v
        if ans > max_n:
            ans = -1
            break
        if ans == 0:
            break
    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:
n=int(input())
a=input()
b=a.replace(' ', '*')
c=eval(b)
ans=int(c)
if ans>100000000000000000:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

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

def ans(a):
    if 0 in a:
        return 0
    n = 1
    for i in a:
        n *= i
        if n > 10**18
            return -1
    return n

print(ans(a))

Submission status: Runtime Error

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

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

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

prin(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int,input().split()))
limit=10**18

if 0 in a:
    print(0)
    exit()

ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(a):
  ans *= a[i]
  if sum> limit:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

# if ans > limit:
#   print(-1)
# else:
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
ans=1
for i in range(N):
    ans=ans*A[]
    if ans>=10**18:
        print(-1)
        exit
    elif ans==0:
        print(0)
        exit
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from decimal import Decimal
l = input().split()

A = int(l[0])
B = Decimal(l[1])

#print('{}'.format(math.floor(A*B)))
print('{}'.format(int(A*B)))

Submission status: Runtime Error

Solution code:
a,b=map(str,input().split())
tempb=float(b)*100
tempa=int(a)
print(int(tempa*tempb/100))

Submission status: Runtime Error

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

 
for i in A:
    ans *= i
    if ans <= 10**18:
        return

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

Submission status: Runtime Error

Solution code:
n = int(input())
num = list(input())
ans = 1
for i in range(n):
    ans *= num[i] 
if ans > 1000000000000000000:
    print("-1")
else:
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def main():
    n = int(input())
    a = sorted(input_list())
    max_n = 10 ** 18
    ans = 1
    for v in a:
        ans *= v
        if ans > max_n:
            print(-1)
            exit()
        if ans == 0:
            print(0)
            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:
N = int(input())
A = [int(x) for x in input().split()]
ans=1
for i in range(N):
    ans=ans*A[]
    if ans>10**18:
        print(-1)
        exit
    elif ans==0:
        print(0)
        exit
print(ans)

Submission status: Runtime Error

Solution code:
a,b=map(str,input().split())
tempb=float(eval(b)*100)
tempa=int(eval(a))
print(int(tempa*tempb/100))

Submission status: Runtime Error

Solution code:
n = int(input())
num = list(input().split())
ans = 1
for i in range(n):
    ans *= num[i] 
if ans > 1000000000000000000:
    print("-1")
else:
    print(ans)

Submission status: Runtime Error

Solution code:
def Multiplication2():

    N=int(input())#入力回数を決める

    list_a=[]

    output = 1

    for i in range(N):

        a = int(input())

        if a >= 0 & a <= pow(10, 18):
            list_a.append(a)
            output = output*a

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

if __name__ == '__main__':
    Multiplication2()

Submission status: Runtime Error

Solution code:
n=int(input())
sum=1
f=0
f2=0
for i in range(1,n):
	a=(input())
	if  (a==0): 
		f2=1
	sum=sum*a
	if (sum>10**18):
		sum=-1
                break
}
if f2==1: 
	print(0)
else:
	print(sum)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break
  elif result > 1000000000000000000
    break

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

Submission status: Runtime Error

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

    if 0 in lst:
        print(0)
        exit()
    for i in map(int, input().split()):
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int,input().split()))
limit=10**18

if 0 in a:
    print(0)
    exit()

# ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(a):
  ans *= a[i]
  if sum>limit:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

# if ans > limit:
#   print(-1)
# else:
print(ans)

Submission status: Runtime Error

Solution code:
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int,input().split()))
limit=10**18

if 0 in a:
    print(0)
    exit()

# ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(a):
  ans *= a[i]
  if sum>limit:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

# if ans > limit:
#   print(-1)
# else:
  print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
array=list(map(int, input().split()))
k=1
a,b=n//2,n%2
if 0 in array:
    print(0)
    exit()
for i in range():
    k*=i
if k>1000000000000000000:
    print(-1)
else:
    print(k)

Submission status: Runtime Error

Solution code:
n = int(input())
 
a = list(map(int, input.split()))
 
res = 1
 
for i in a:
  res *= i
 
if res > pow(10, 18):
  print("-1")
else:
  print(str(res))

Submission status: Runtime Error

Solution code:
from decimal import Decimal
N=Decimal(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:
n = int(input())

l = list(map(int, input().split())).sort()

if l[0] == 0:
  print(0)
  exit()
res = 1

for i in l:
  res *= i
  if res > 10 **18:
    print(res)
    exit()
  print(res)

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(input().split()))
ans = 1
if 0 in a:
  ans = 0
for i in range(n):
  ans *= a[i]
  print(i)
if ans >= 10**18:
  ans = -1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
from decimal import *
import numpy as np
a = np.array(list(map(Decimal, input().split())))
p = np.prod(a, axis=0)
if p > 10**18:
    print(-1)
else:
    print(p)

Submission status: Runtime Error

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

ans=1
if 0 in x:
  print(0)
  break
  for i in x:
    ans=ans*i  
if ans>=1000000000000000000:
  ans=-1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
def main():

    n=int(input())
    p=list(map(int,input().split()))
    s=1
    p=sorted(p)
    for i in p:
        s*=i
        if i==0:
            print(0)
            sys.exit()
        else s>=10**18+1:
            print(-1)
            sys.exit()
    print(s)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
arr = map(int, input().split())
zero = False
ans = 1
ok = True
for e in arr:
	if e == 0:
		zero = True
		break
	ans = ans * e;
	if ans > 10**18:
		ok = False
        break
if zero:
	print(0)
else:
	if ok:
		print(ans)
	else:
		print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())
arr = list(map(int, input().split()))
zero = False
ans = 1
ok = True
for e in arr:
	if e == 0:
		zero = True
		break
	ans = ans * e;
	if ans > 10**18:
		ok = False
        break
if zero:
	print(0)
else:
	if ok:
		print(ans)
	else:
		print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())
arr = list(map(int, input().split()))
zero = False
ans = 1
ok = True
for e in arr:
	if e == 0:
		zero = True
        break
	ans = ans * e;
	if ans > 10**18:
		ok = False
        break
if zero:
	print(0)
else:
	if ok:
		print(ans)
	else:
		print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
pr= 1
for i in l:
    pr= pr* i
if len(pr)>19:
    print(-1)
else:
    print(pr)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a= input()

list1 = [ a for items in list1 list1[items]=input() ]

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
for a in A:
    if a == 0:
        zero_flag = 1
        result = 0
        break
    else:
        result = result * a
        if result > pow(10, 18):
            flag = 1
            result = 0
if flag == 1 and zero_flag != 1:
    print(-1)
else:
    print(result)

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:
N = int(input())
A = N.split(" ")
A = list(map(int, A))
result = A[0]
for i in range(1,N):
  result = result*A[i]
  if result*A[i] > 10**18:
    print("-1")
    exit()
print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
s = sorted(map,int,input().split())
M = 10 ** 18
ans = 1
for ss in s:
	ans *= ss
	if ans > M:
		ans = -1
		break
	elif ans == 0:
		break
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = sorted(map,int,input().split())
M = 10 ** 18
ans = 1
for ss in s:
	ans *= ss
	if ans > M:
		ans = -1
		break
	elif ans == 0:
		break

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 c >= 25:
      pritn("-1")
      exit()
    else:
      continue
print(ans if ans <= 10**18 else "-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.tie(0);
	if (res > 1000000000000000000) cout << -1;
	else cout << res;
}