Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Runtime Error

Solution code:
n = int(input())
number = list(map(int, input().split()))
seki = 0
seki2 = -1
for i in numebr:
  seki = seki*i
 if seki > 10 ** 18:
  print(seki2)
 else:
  print(seki)

Submission status: Runtime Error

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

max = pow(10, 18)
result = 1
for num in num_list:
  if num == 0:
    print(0)
    break
    else:
      result = result * num
      if result > max:
        print(-1)
        break 
        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.int64)

#
ans =0
if 0 in A:
    ans =0:
else:
    ans =np.prod(A)
    if ans >10**18:
        ans =-1
print(ans)

Submission status: Runtime Error

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

ans = 1
ng = false
max = 10**18
for A in Aj:
	if A == 0:
		ans = 0
		break
	if ans*A > max:
		ans *= A
print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 200001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x,ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans;
    }
    else ans = fast_exp(x, n - 1) * x;
    return ans;
}
ll a[N], b[N], c[N], o[N], z[N];
vector<int> tree[N];
ll solve(ll x, ll p)
{
    ll ans = 0;
    for(auto i:tree[x])
    {
        if(i != p)
        {
            a[i] = min(a[i], a[x]);
            ans += solve(i, x);
            o[x] += o[i];
            z[x] += z[i];
        }
    }
    if(b[x] != c[x])
    {
        if(b[x]) o[x]++;
        else z[x]++;
    }
    if(o[x] && z[x])
    {
        ans += 2 * a[x] * min(o[x], z[x]);
        ll y = min(o[x], z[x]);
        o[x] -= y;
        z[x] -= y;
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 0, ans = 1, k;
        cin >> n;
        long double tmp = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x;
            tmp += log10(x);
            if(tmp <= 18)
                ans = x * ans;
            else ans = -1;
            if(x == 0) y = 1;
        }
        if(y) ans = 0;
        cout << ans << "\n";
     }
     return 0;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 200001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x,ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans;
    }
    else ans = fast_exp(x, n - 1) * x;
    return ans;
}
ll a[N], b[N], c[N], o[N], z[N];
vector<int> tree[N];
ll solve(ll x, ll p)
{
    ll ans = 0;
    for(auto i:tree[x])
    {
        if(i != p)
        {
            a[i] = min(a[i], a[x]);
            ans += solve(i, x);
            o[x] += o[i];
            z[x] += z[i];
        }
    }
    if(b[x] != c[x])
    {
        if(b[x]) o[x]++;
        else z[x]++;
    }
    if(o[x] && z[x])
    {
        ans += 2 * a[x] * min(o[x], z[x]);
        ll y = min(o[x], z[x]);
        o[x] -= y;
        z[x] -= y;
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 0, ans = 1, k;
        cin >> n;
        long double tmp = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x;
            ans = x * ans;
            tmp += log10(x);
        }
        if(tmp > 18) ans = -1;
        cout << ans << "\n";
     }
     return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
number=[int(x) for x in input().split()]
 
for numb in number:
  sum *= numb
if(sum > pow(10,18)):
	print(-1)
else:
  print(sum)

Submission status: Runtime Error

Solution code:
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
  if total_pow > 10**18:
  	if "0" in input_list.split(" "):
      print("0")
    else:
      print("-1")
  	sys.exit()

print(total_pow)

Submission status: Runtime Error

Solution code:
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
  if total_pow > 10**18:
  	if "0" in input_list.split(" "):
      print("0")
    else:
      print("-1")
  	sys.exit()
print(total_pow)

Submission status: Runtime Error

Solution code:
n = int(input(""))
i=0
sum = 1
while i < n:
    i += 1
    x = int(input(""))
    sum = sum * x
if sum >= 10*10*10*10*10*10*10*10:
    print(-1)
else:
    print(sum)

Submission status: Runtime Error

Solution code:
input_num = input()
input_list = input()

total_pow = 1
[total_pow*=int(num) for num in input_list.split(" ")]

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

Submission status: Runtime Error

Solution code:
n = int(input())
num_list=list(map(int,input().split()))
ans = 1
for i in n:
  ans = ans*num_list[i]
if ans <1000000000000000000:
  print(ans)
else:
  print("-1")

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
ans = n *m
if ans <1000000000000000000:
  print(ans)
else:
  print("-1")

Submission status: Runtime Error

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

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
    result *= i
    if result > 10**18:
        result = -1
        break

print(result)

Submission status: Runtime Error

Solution code:
result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10**18:
            result = -1
            break

print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
arrA = [int(x) for x in input().split()] 

v2 = 10**18

re = 1
for j in arrA:
    re *= j

if re > v2:
    print(-1)
else:
    print(re

Submission status: Runtime Error

Solution code:
arrA = []
n = int(input())
for i in range(n):
    valor = int(input())
    arrA.append(valor)

v1 = 10**5
v2 = 10**18

re = 1
for j in arrA:
    re *= j

if re > v2:
    print(-1)
else:
    print(re

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
        break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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





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

Submission status: Runtime Error

Solution code:
    from functools import reduce
    n = int(input())
    tab = [int(n) for n in input().split()]
    if 0 in tab:
      print("0")
    res = reduce(lambda x, y: x*y, tab)
    if res > 1000000000000000000:
      print("-1")
    else:
      print(res)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math
a = int(input())
for _ in range(a):
    b, c = map(int, input().split(' '))
    if b*c == 10**18:
        print("-1")
    else:
        print(b*c)

Submission status: Runtime Error

Solution code:
import math
a = int(input())
for _ in range(a):
    b, c = map(long, input().split(' '))
    if b*c == 10**18:
        print("-1")
    else:
        print(b*c)

Submission status: Runtime Error

Solution code:
n = int(input());
ans = 1;
zero = false
for i in map(int, input().split()):
    ans *= i
    if i==0:
        zero = true
print(ans if ans>=0 else -1);

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import functools
n = int(input())
lis = map(int,input().split())
if 0 in lis:
  print(0)
else:
  
  g = functools.reduce(lambda a,b : a*b,)
  if g > 10**18:
      print(-1)
  else:
      print(g)

Submission status: Runtime Error

Solution code:
def main():
  n = int(input())

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

	ans = 1

  for x in l:
    ans = ans*x
    if(ans > 1000000000000000000):
      print(-1)
      return


  print(ans)

main()

Submission status: Runtime Error

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

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

ans = 1
for i in a:
  ans *= a

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

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    n = input()
    nums = input().split(' ')]
    f = pow(10, 18)

    result = 1
    for i in range(int(n)):
        if str(0) in nums:
            result = 0
            break

        result = result * int(nums[i])
        if result > f:
            result = -1
            break

    print(result)

Submission status: Runtime Error

Solution code:
n = int(input())

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

for x in l:
  ans = ans*x
  
if(ans > 1000000000000000000):
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [map(int, input().split()) for _ in range(n)]

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

Submission status: Runtime Error

Solution code:
a, b = map(float,input().split())
print(int((a*b)//1))

Submission status: Runtime Error

Solution code:
n = int(input())
num = list(map(int, input().split()))
limit = 10**18
 
num.sort()
result = A[0]
 
for i in num[1:]:
    result *= i
    if result > limit:
        exit()
        
print(result)

Submission status: Runtime Error

Solution code:
a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        return
print(b)

Submission status: Runtime Error

Solution code:
a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    return
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)

Submission status: Runtime Error

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    return

b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        return
print(b)

Submission status: Runtime Error

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

ans = 1
for a in ans:
  if ans >= 10**(18)/a:
	ans = -1
    break
  else:
    ans *= a

if 0 in A:
  print(0)
else:
  print(ans)

Submission status: Runtime Error

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

print(prod)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) <= 1e18 or x < 0 or y < 0  else (X * y)), inputs)

print(output)

Submission status: Runtime Error

Solution code:
    import numpy as np
    n = int(input())
    nums = map(int, input().split())
    print(np.prod([i for i in list(nums)]))

Submission status: Runtime Error

Solution code:
    import numpy as np
    n = int(input())
    nums = map(int, input().split())
    print(np.prod([i for i in nums]))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
nums = map(int, input().split())
print(np.prod([i for i in nums])

Submission status: Runtime Error

Solution code:

N=int(input())

data=[int(e) for e in input().split()]

data=data.sort(reverse=False)

judge=True

for i in data:
    sum_1=sum_1*i

    if sum_1>1000000000000000000:
        print("-1")
        judge=False
        break

if judge==True:
    print(sum_1)

Submission status: Runtime Error

Solution code:
n=int(input())
arr=[]
arr=list(map(int,input().split()))
mul=1
for i in range(n):
  mul*=arr[i]
  if(mul>1000000000000000000):
    print("-1")
    return
print(mul)

Submission status: Runtime Error

Solution code:
import math
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  return
for x in i:
  result *= x
  if(len(str(result)) >= 19):
    print(-1)
    return
print(result)

Submission status: Runtime Error

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

if 0 in li:
  print(0)
else:
  result = 1
  flag = True
  for i in range(n):
    result *= li[i]
    if result > 10 ** 18:
      flag = False
      print(-1)
      break
if flag == True:
  print(result)

Submission status: Runtime Error

Solution code:
n=int(input())
array=[]
for i in range(n):
    array+=[int(input())]
flag=0
flag2=0
s=1
for m in range(len(array)):
    if array[m]==0:
        flag=1
        break
    s=s*array[m]
    if s>10**18:
        flag2=1
        break

if flag==1:
    print("0")
elif flag==2:
    print("-1")
else:print(s)

Submission status: Runtime Error

Solution code:
list = input().split()
if "0" in list:
  print(0)
else:
  answer = 1
  for i in list:
    answer = answer * int(i)
 	if answer > 1000000000000000000:
      print(-1)
  print(answer)

Submission status: Runtime Error

Solution code:
a = [int(map(int, input.split())) for i in range(n)]
a1 = a[0]
a2 = a[1]
ans = 1
for r in range(a[0]):
  ans *= a2[r]
print(ans)

Submission status: Runtime Error

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

for r in range(0,len(a)):
  ans *= a[r]
  
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        return
print(ans)

Submission status: Runtime Error

Solution code:
import decimal
N = int(input())
A = list(input().split())

ans = 1
for i in range(len(A)):
    ans *= decimal.Decimal(A[i])
    
if(len(str(ans)) >= 18):
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
input()
l = 10**18
a = 1
for i in map(int, input()):
    a *= i
    if a > l:
        a = -1
        break
print(a)

Submission status: Runtime Error

Solution code:
import numpy as np

N=int(input())
A=np.ones(N)
a=np.ones(N)

A=map(int,input().rstrip().split())


a=sorted(A,reverse=True)

a_product=1
flag_1e18=False
flag_0=False

if a[N-1]==0:
  flag_0=True

for i in range(0,N,1):
  a_product=a_product*a[i]
  if a_product>1e18:
    flag_1e18=True
    break
  else:
    continue
    
if flag_1e18==True and flag_0==False:
  print(-1)
elif flag_0==True:
  print(0)
else:
  print(A_product)

Submission status: Runtime Error

Solution code:
import numpy as np

N=int(input())
A=np.ones(N)
a=np.ones(N)

A=map(int,input().rstrip().split())


a=sorted(A,reverse=True)

a_product=1
flag_1e18=False
flag_0=False

if a[N-1]==0:
  flag_0=True

for i in range(0,N,1):
  a_product=a_product*a[i]
  if a_product>1e18:
    flag_1e18=True
  else:
    continue
    
if flag_1e18==True and flag_0==False:
  print(-1)
elif flag_0==True:
  print(0)
else:
  print(A_product)

Submission status: Runtime Error

Solution code:
n=int(input())
ans=1
a=list(input().split(' '))
for i in list:
  ans=ans*i
  if ans>=int(1e18):
    print(-1)
    break
if ans<=int(1e18):
  print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin

n = stdin.readline().rstrip().split()
a = stdin.readline().rstrip().split()

total = 1
for i in a:
    total = total*int(i)
	if(total > 1000000000000000000):
      total = -1
      break
    
print(total)

Submission status: Runtime Error

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

    if a.index(0)==1:
        print(0)
        return

    for i in range(N):
        cal*=a[i]
        if cal>=10**18:
            print("-1")
            return

    print(cal)
    return


main()

Submission status: Runtime Error

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

    if a.index(0):
        print(0)
        return
        
    for i in range(N):
        cal*=a[i]
        if cal>=10**18:
            print("-1")
            return

    print(cal)
    return


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
ans=1
flag=0
for i in n:
  x=input()
  ans*=x
  if(ans>(10**18)):
    flag=1
    break

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int, input().split()))
cal=1
i=0
while i <= range(N):
    cal*=A[i]
    i+=1
if cal>=10**18:
        print(-1)
else:
        print(cal)

Submission status: Runtime Error

Solution code:
import math

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

ans = 1
for i in a_lis:
    if math.log(i, 10) + math.log(ans + 10) > 18:
        ans = -1
        break
    
    else:
        ans += i
        
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
An = list(map(int, input().split()))
sum = 1
for i in range(N):
  sum *= An[i]
  if sum > 1e18:
    print(-1)
    quit()
  else sum == 0:
    print(0)
    quit()
print(sum)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def main():
  n=int(input())
  arr=list(map(int,input.split()))
  prod=1
  for i in range(0,n):
    prod*=arr[i]
    if(prod>=1000000000000000000):
      print(-1)
      return
    
  print(prod)

  
main()

Submission status: Runtime Error

Solution code:
def cal():
  n=int(input())
  arr=list(map(int,input.split()))
  prod=1
  for i in range(0,n):
    prod*=arr[i]
    if(prod>=1000000000000000000):
      print(-1)
      return
  print(prod)
  return

cal()

Submission status: Runtime Error

Solution code:
A=int(input())
B=input().split(" ")
D=1
for C in B:
  D=D*int(C)
  if D>10^18:
    D=-1
    break
  elif C=0:
    D=0
    break
  else:
    continue
print(D)

Submission status: Runtime Error

Solution code:
defmain():N =int(input())A =list(map(int,input().split()))if0inA:print(0)returnprod = 1forainA:prod *= aifprod > 1000000000000000000:print(-1)returnprint(prod)main()

Submission status: Runtime Error

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

if 0 in arr:
    print("0")
else:
    tot = 1
    arr = sorted(arr, reverse=True)
    done = False
    for x in arr:
        tot *= x
        if tot > MAX:
            print("-1")
            done = True
    if not done:
        print(tot)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
l = 1
for i in range(n):
  j = int(raw_input())
  l=l*j
if(l>1000000000000000000):
  print("-1")
else:
  print(l)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

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

for a in A:
	if a == 0:
		print("0")
		sys.exit()

num = 1
for a in A:
	num *= a
	if num > 1000000000000000000:
		print(-1)
		sys.exit()

print(num)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[map(int,input().split())]
sorted(A)
if A[0] == 0:
  print(0)
  exit(0)

ans = 1
for i in range(N):
  ans*=A[i]
  if(ans>1000000000000000000):
    print(-1)
    exit(0)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
nums = input().split()
mul = int(nums[0])
for i in nums[1:]:
    if str(0) in mul:
        mul = 0
        break
    if len(str(mul)) > 19:
        mul = -1
        break
    mul *= int(i)
print(mul)

Submission status: Runtime Error

Solution code:

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

S = 1
for i in range(1, N):
	S *= A[i]
	if S > 1000000000000000000:
         print(-"1")
	
print(S)

Submission status: Runtime Error

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

S = A[0]

for i in range(1, N):
	S = S * A[i]
	if S > 10**18:
         print(-"1")

print(S)

Submission status: Runtime Error

Solution code:
e = 10 ** 18
n = int(input())
arr = [int(i) for i in input().split()]
ans, flag = [1,1]
if 0 in arr:
  print('0')
else:
  for i in arr:
  	ans = ans * i
  	if ans > e:
    	print('-1')
    	flag = 0
    	break
if flag == 1:
  print(ans)

Submission status: Runtime Error

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

S = A[0]
for i in range(1, N):
	S = S * A[i]
	if S > 10**18:
         print(-"1")
print(S)

Submission status: Runtime Error

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

S = A[0]
for i in range(1, N):
	S = S * A[i]
	if S > 10**18:
         print(-"1")
print(S)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
list = []
Point=1
for i in range(N):
    list.append(int(input()))
for val in list:
    Point = Point * val

print(Point)

Submission status: Runtime Error

Solution code:
def main():
N=int(input())
A=list(map(int,input().split()))
if A is 0:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)  
main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
if A is 0:
  print(0)
  return
p=1
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    return
print(p)

Submission status: Runtime Error

Solution code:
N = int(input()) #1行目のNを取得する
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得
ans =1
for num in s:
    ans *= num
    if ans > 10**18:
        ans = -1
        break
        
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())

A = lit(map(int, input().split()))

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

limit = 10**18

result = 1
for value in A:
    result *= value
    if result > limit:
        result = -1
        break

print(result)

Submission status: Runtime Error

Solution code:
N = int(input())

A = lit(map(int, input().split()))

if 0 in A:
    print(0)
    return
    
limit = 10**18

result = 1
for value in A:
    result *= value
    if result > limit:
        result = -1
        break

print(result)

Submission status: Runtime Error

Solution code:
n = i#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mx=1e18;
ll arr[100000];


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
     ll n;
     cin>>n;
     for(ll i=0; i<n; ++i){
        cin>>arr[i];
     }
     for(ll i=0; i<n; ++i){
        if(arr[i]==0){
            cout<<0<<"\n";
            return 0;
        }
     }
     ll p=1;
     for(ll i=0; i<n; ++i){
        if(arr[i]<=mx/p) p*=arr[i];
        else {
            cout<<-1<<"\n";
            return 0;
        }
     }
     cout<<p<<"\n";   

}

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = [int(c) for c in input().split(' ')]

ret = np.prod(A, dtype='float128')
if int(ret) > 1e18:
  print(-1)
else:
  print(ret)

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
arr = [int(x) for x in input().split()]
goukei = 1
ok = 1
if 0 in arr:
  print(0)
  ok = 0
for i in arr:
  goukei *= i
  if goukei>=1000000000000000000:
    print(-1)
    ok = 0
    break
if ok = 1:
  print(goukei)