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=i#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
ll modInverse(ll a, ll m)
{
    ll g = gcd(a, m);
    return(power(a,m-2,m));
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/
bool isprime(ll x)
{
    if(x==1)
        return(false);
    for(ll i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return(false);
    }
    return(true);
}
vector<ll> v[100005];
bool vis[100005]={false};
long combi(int n,int k)
{
    long ans=1;
    k=k>n-k?n-k:k;
    int j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}

void solve()
{
    ll n;
    cin>>n;
    ld arr[n];
    ld s=1;
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    for(ll i=0;i<n;i++)
    {
        s*=arr[i];
        //cout<<s<<endl;
        /*if(s>pow(10,18))
        {
            cout<<-1<<endl;
            return;
        }*/
    }
    if(s>pow(10,18))
{
    cout<<-1<<endl;
    return;
}
    cout<<ull(s)<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}

Submission status: Runtime Error

Solution code:
import math

n = int(input())
aa = map(int, input().split())
s = math.prod(aa)
if s > 10**18:
    print(-1)
else:
    print(s)

Submission status: Runtime Error

Solution code:
A = int(input())
list=[]
for i in range(A):
  list.append(int(input()))
  
sum=1
for i in range(A):
  sum = sum*list[i]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

N = int(input())

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



ans = 1

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

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
nums = list(map(int, input().split(' ')))

output = 1

if 0 in nums:
  print(0)
  sys.exit()
  
else:
  for x in nums:
    output *= x

    if output > 10**18:s
      print('-1')
      sys.exit()

  print(output)

Submission status: Runtime Error

Solution code:
n = int(input())
apple = eval(input().replace(" ", "*"))
print(apple if apple <= 10**18 else -1)

Submission status: Runtime Error

Solution code:
n=int(input())
a = list(map(int,input().split()))
a = a.sort(reverse=true)
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        ans = -1
        break
print(ans)

Submission status: Runtime Error

Solution code:
ans = 1
for i in a:
    ans *= i
    if ans > pow(10,18):
        print(-1)
        break
print(ans)

Submission status: Runtime Error

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

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        sum = sum * i
    if np.log10(sum) >= 18:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math 
N =int(input())
A = list(map(int,input().split()))
Sum = 1
for i in range(N):
  Sum *= A[i]

if math.log10(Sum) > 18:
  print(-1)
else:
  print(Sum)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
//#define int ll 
long const M=1e9+7;
const ll mxN =1e18+2 ;
void solve(){
  ll n ,ans=1;
  cin >> n ;
  For(i,n){
    ll x ;
    cin >> x ;
    ans*=x ;
    if(ans>mxN){
      pf(-1) ;
      return ;
    }
  }
  pf(ans) ;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  //ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}

Submission status: Runtime Error

Solution code:
import numpy as np
n = input()
prod_val = np.prod(list(map(int,input().split())))
print("-1" if prod_val > 10**18 else prod_val)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
Alist = []
for i in range(N):
    Alist.append(int(input()))

p = np.prod(Alist)
if p >= 10**18:
    print("-1")
else:
    print(p)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define endl '\n'
#define ff first
#define ss second
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define print(a) for(auto x : a) cout << x << " "; cout << endl;

using namespace std;

const ll inf = 1e18 + 42;

const ll M = 998244353;

ll power(ll x, ll y) {
	if (y == 0) return 1;
	if (y & 1) return (x * power(x, y - 1));
	ll t = power(x, y / 2);
	return (t * t);
}

const ll MAX = 1e3 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void ahShitHereWeGoAgain()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll ans = 1;
	ll zero = 0;
	for(ll i = 0; i < n; i++)
	{
		cin >> a[i];
		zero++;
	}
	if(zero)
	{
		cout << 0 << endl;
		return;
	}
	for(ll i = 0; i < n;i++)
	{
		ll x; cin >> x;
		ans = ans * x;
		// deb(ans);
		if(ans > 1000000000000000000)
		{
			cout << -1 << endl;
			return;
		}
	}
	cout << ans << endl;
}

int main()
{
	DESYNC	
	ll t = 1;
	// cin >> t;
	while (t--)
		ahShitHereWeGoAgain();
	return 0;
}

Submission status: Runtime Error

Solution code:
/* nuttela - Soham Chakrabarti */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define ins insert
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define per(i,j,k) for(ll i=j;i>=k;--i)
#define in freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define ff first
#define ss second
 
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll,ll> pll;
 
const int N = 2e5 + 5;
const int M = 1e5 + 1;
const int inf = INT_MAX;
const int mod = 1e9 + 7;

int32_t main() {
    io;
    // in; out;
    ll n;cin>>n;
    ull a[n];
    rep(i,0,n)cin>>a[i];
    bool fl=0;
    ull ans=1;
    rep(i,0,n) {
        ans*=a[i];
    }
    if(ans>=1e18)
        cout<<-1<<endl;
    else
        cout<<ans<<endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
def resolve():
    N = int(input())
    list = list(map(int, input().split()))
    lists = np.array(list)
    print(np.prod(lists) if np.prod(lists)<=10**18 else "-1")
resolve()

Submission status: Runtime Error

Solution code:
limit = 1E18
n = input()
total = 0
for i in range(n):
  x = input()
  total += x
  if total > limit:
    print(-1)
    exit()
    
print(total)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
prod = math.prod(a, start=1)
if prod > 10**18:
  print(-1)
else :
  print(prod)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
A = list(map(int, input().split()))
result=1
limit=10**18
flg0=0
for i in range(n):
  if A[i] == 0:
    flg0=1
    print('0')
for i in range(n):
  if flg0 == 1:
    break
  result *= A[i]
  if result > limit:
    print('-1')
    flg=1
    break
if flg != 1 and flg0 != 1:
  print(result)

Submission status: Runtime Error

Solution code:
def resolve():
    from decimal import Decimal
    import numpy as np

    n = int(input())
    A = np.array(list(map(Decimal, input().split())))
    a = np.prod(A)
    if a > 10**18:
        print(-1)
    else:
        print(a)

resolve()

Submission status: Runtime Error

Solution code:
n = int(input())
lt = [int(x) for x in input().split()]
if 0 in lt:
    print(0)
else:
    ans = 1 
    for x in lt:
       ans*=x 
       if ans > 10**18:
           ans=-1
print(ans)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())

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

NList.sort()
result = 1
for i in range(N):
    result *= NList[i]

    if result > 10 ** 18:
        print('-1')
        sys.exit(1)

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

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
b = sum(a.log(10))
c = 10 ** b
if c > 10 ** 18:
  print("-1")
else:
  print(b)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for n in range(N):
  A = int(input())
  if A == 0:
    result = 0
    break
  result = result*A
  if result>1000000000000000000:
    result = -1
    break

print(result)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
 
 
class BigNum {
public:
    static const int MOD = 100000000;
    static const int BIT = 8, SIZE = 105;
    mutable int n, o;
    long long u[SIZE];
    BigNum() {}
    BigNum(const string& s) {
        memset(this, 0, sizeof(BigNum));
        int num = 0, cnt = 1;
        for (int i = s.size() - 1; ~i; i--) {
            if (s[i] == '-') o ^= 1;
            if (s[i] >= '0' && s[i] <= '9') {
                num += (s[i] - '0') * cnt;
                cnt *= 10;
                if (cnt == MOD) u[n++] = num, num = 0, cnt = 1;
            }
        }
        if (!n || cnt >= 10) u[n++] = num;
        if (!u[0] && n == 1) o = 0;
    }
    BigNum(long long x) {
        memset(this, 0, sizeof(BigNum));
        if (x < 0) o = 1, x = -x;
        do u[n++] = x % MOD; while (x /= MOD);
    }
    operator string() const {
        static char s[SIZE * BIT + 10];
        char* c = s + sprintf(s, "%s%d", o ? "-" : "", int(u[n - 1]));
        for (int i = n - 2; ~i; i--) c += sprintf(c, "%0*d", BIT, int(u[i]));
        return s;
    }
    int operator [](int pos) const {
        static int e[BIT] = {1};
        for (static int i = 1; i < BIT; i++) e[i] = e[i - 1] * 10;
        return u[pos / BIT] / e[pos % BIT] % 10;
    }
    int length() const {
        int ret = (n - 1) * BIT + 1;
        for (int x = u[n - 1] / 10; x; x /= 10) ret++;
        return ret;
    }
    friend int cmp(const BigNum& l, const BigNum& r) {
        if (l.o != r.o) return (l.o ? -1 : 1);
        if (l.n != r.n) return (l.o ? -1 : 1) * (l.n - r.n);
        for (int i = l.n - 1; ~i; i--) if (l.u[i] - r.u[i])
                return (l.o ? -1 : 1) * (l.u[i] - r.u[i]);
        return 0;
    }
    // 运算符
    bool operator < (const BigNum& r) const {return cmp(*this, r) < 0;}
    bool operator > (const BigNum& r) const {return cmp(*this, r) > 0;}
    bool operator <=(const BigNum& r) const {return cmp(*this, r) <= 0;}
    bool operator >=(const BigNum& r) const {return cmp(*this, r) >= 0;}
    bool operator ==(const BigNum& r) const {return cmp(*this, r) == 0;}
    bool operator !=(const BigNum& r) const {return cmp(*this, r) != 0;}
    BigNum operator +(const BigNum& r) const {return BigNum(*this) += r;}
    BigNum operator -(const BigNum& r) const {return BigNum(*this) -= r;}
    BigNum operator *(int x) const {return BigNum(*this) *= x;}
    BigNum operator /(int x) const {return BigNum(*this) /= x;}
    BigNum& operator *=(const BigNum& r) {return *this = *this * r;}
    BigNum& operator /=(const BigNum& r) {return *this = *this / r;}
    BigNum& operator %=(const BigNum& r) {return *this = *this % r;}
    BigNum& operator %=(int x) {return *this = *this % x;}
    BigNum operator -() const {
        BigNum s = *this;
        if (s.u[0] || s.n >= 2) s.o ^= 1;
        return s;
    }
    BigNum& operator +=(const BigNum& r) {
        if (r.n == 1 && !r.u[0]) return *this;
        if (r.o ^ o) return r.o ^= 1, *this -= r, r.o ^= 1, *this;
        if (r.n > n) n = r.n;
        for (int i = 0; i < r.n; i++) u[i] += r.u[i];
        for (int i = 0; i < n; i++) if (u[i] >= MOD) u[i + 1]++, u[i] -= MOD;
        if (u[n]) n++;
        return *this;
    }
    BigNum& operator -=(const BigNum& r) {
        if (r.n == 1 && !r.u[0]) return *this;
        if (r.o ^ o) return r.o ^= 1, *this += r, r.o ^= 1, *this;
        if (cmp(*this, r) * (r.o ? -1 : 1) < 0) {
            o ^= 1, n = r.n;
            for (int i = 0; i < r.n; i++) u[i] = r.u[i] - u[i];
        } else {
            for (int i = 0; i < r.n; i++) u[i] = u[i] - r.u[i];
        }
        for (int i = 0; i < n; i++) if (u[i] < 0) u[i + 1]--, u[i] += MOD;
        while (!u[n - 1] && n >= 2) --n;
        if (!u[0] && n == 1) o = 0;
        return *this;
    }
    BigNum operator *(const BigNum& r) const {
        BigNum s = 0;
        if (!u[n - 1] || !r.u[r.n - 1]) return s;
        s.n = r.n + n - 1;
        s.o = r.o ^ o;
        for (int i = 0; i < n; i++) for (int j = 0; j < r.n; j++)
                s.u[i + j] += u[i] * r.u[j];
        for (int i = 0; i < s.n; i++) if (s.u[i] >= MOD) {
                s.u[i + 1] += s.u[i] / MOD;
                s.u[i] %= MOD;
                if (i == s.n - 1) s.n++;
            }
        return s;
    }
    BigNum operator /(const BigNum& r) const {
        BigNum e[35], s = 0, c = 0;
        int m = 0, ro = r.o, lo = o;
        r.o ^= ro, o ^= lo;
        for (e[m] = r; MOD >> ++m; e[m] = e[m - 1] + e[m - 1]);
        for (int i = n - 1; ~i; i--) {
            int tag = 0;
            (s *= MOD) += u[i];
            for (int x = m - 1; ~x; x--) if (s >= e[x]) s -= e[x], tag |= 1 << x;
            (c *= MOD) += tag;
        }
        r.o ^= ro, o ^= lo;
        if (c.u[0] || c.n >= 2) c.o = r.o ^ o;
        return c;
    }
    BigNum operator %(const BigNum& r) const {
        BigNum e[35], s = 0;
        int m = 0, ro = r.o, lo = o;
        r.o ^= ro, o ^= lo;
        for (e[m] = r; MOD >> ++m; e[m] = e[m - 1] + e[m - 1]);
        for (int i = n - 1; ~i; i--) {
            (s *= MOD) += u[i];
            for (int x = m - 1; ~x; x--) if (s >= e[x]) s -= e[x];
        }
        r.o ^= ro, o ^= lo;
        if (s.u[0] || s.n >= 2) s.o = o;
        return s;
    }
    BigNum& operator *=(int x) {
        if (!x) return *this = 0;
        if (x < 0) o ^= 1, x = -x;
        for (int i = 0; i < n; i++) u[i] *= x;
        for (int i = 0; i < n; i++) if (u[i] >= MOD) {
                u[i + 1] += u[i] / MOD;
                u[i] %= MOD;
                if (i == n - 1) n++;
            }
        if (!u[0] && n == 1) o = 0;
        return *this;
    }
    BigNum& operator /=(int x) {
        if (x < 0) o ^= 1, x = -x;
        for (int i = n - 1; i; u[i--] /= x) u[i - 1] += u[i] % x * MOD;
        for (u[0] /= x; n >= 2; n--) if (u[n - 1]) break;
        if (!u[0] && n == 1) o = 0;
        return *this;
    }
    int operator %(int x) const {
        long long c = 0;
        for (int i = n - 1; ~i; i--) c = (c * MOD + u[i]) % x;
        return (1 - o - o) * int(c);
    }
};
BigNum gcd(BigNum x, BigNum y)
{
    while (y != BigNum(0))swap(x %= y, y);
    return x;
}
 
int n;
ll a[maxn];
BigNum x;
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    cin >> n;
    repd(i, 1, n)
    {
        cin >> a[i];
    }
    x = 1;
    repd(i, 1, n)
    {
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    repd(i,1,n)
    {
        x *= (BigNum)(a[i]);
        if (x > 1000000000000000000ll)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (string)(x) << endl;
    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

sum = 0
i = 0

while i <= n:
  x = int(input())
  sum *= x
  i += 1
  
  if sum > 10 ** 18:
    break
    print(-1)
    
print(sum)

Submission status: Runtime Error

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

ret = 1
for a in A:
  ret *= a
  if a == 0:
    ret = 0
    break
  if a > 10 ** 18:
    ret = -1
    break
print( ret )

Submission status: Runtime Error

Solution code:
n=int(input())
p=list(map(int,input().split())
s=1
for i in range(n):
       s=s*p[i]
if s<=pow(10,18):
       print(s)
else:
       print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
if t > 1e18:
    print(-1)
else:
    print(np.prod(A))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
lista = [int(e) for e in input().split()]
lista = np.array(lista)
ans = np.cumprod(lista)

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
s=eval(input().replace(" ", "*"))
print([-1,s][s<=10**18])

Submission status: Runtime Error

Solution code:
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt
from copy import copy, deepcopy
from collections import deque
from fractions import gcd

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

a = int(sys.stdin.readline().strip())
arr = map(int, sys.stdin.readline().strip().split())

x = reduce(lambda x, y: x*y, arr)

print(x if x < 10**18 else -1)

Submission status: Runtime Error

Solution code:
import math
import numpy as np

N = int(input())
A = list(map(int,input().split()))
ans = 1
A_log = list(map(math.log10,A))

if sum(A_log) >= 18:
    print(-1)
else:
    for i in A:
        ans *= i
    print(ans)

Submission status: Runtime Error

Solution code:
t = int(input())
while t!=0:
 x = int(input())
 y = int(input())
 print(x*y)
 t=t-1

Submission status: Runtime Error

Solution code:
n=int(input())
a = [int(x) for x in input().split()]
x=1
b=True
for ai in a:
	if ai==0:
		b=True
		x=0
		break
	if x<=1e18+0.02:
		x*=ai
	if x>1e18+0.002:
		b=False
		continue
	
  
if(b):
  print(x)
else:
	print(-1)

  n=int(input())
a = [int(x) for x in input().split()]
x=1
b=True
for ai in a:
	if ai==0:
		b=True
		x=0
		break
	if x<=1e18+0.02:
		x*=ai
	if x>1e18+0.002:
		b=False
		continue
	
  
if(b):
  print(x)
else:
	print(-1)

Submission status: Runtime Error

Solution code:
a=int(input())
mul=1
l=[]
for i in range(a):
  x=int(input())
  l.append(x)
for i in l:
  mul=mul*i
if mul>1000000000000000000:
  print('-1')
else:
  print(mul)

Submission status: Runtime Error

Solution code:
def resolve():
    N = int(input())
    list = list(map(int, input().split()))
    print(np.prod(list) if np.prod(list)<=10**18 else "-1")
resolve()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> vec(N);
    ll sum = 1;
    bool ok = true;
    for (ll i = 0; i < N; i++)
    {
        ll ai;
        cin >> ai;
        sum *= ai;
        if (sum > 1000000000000000000LL || sum < 0LL) {
            ok = false;
        }
    } 
    if (ok || sum == 0) {
        cout << sum << endl;
    } else {
        cout << -1 << endl;
    }
    
}

Submission status: Runtime Error

Solution code:
n = int(input())
l = input().split(" ")
tmp = 1
for item in l:
    tmp *= item
if tmp > (10**18):
    print(-1)
else:
    print(tmp)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
if 0 in set(a):
  print(0)
else:
   p,q = 1,q
   
   for i in range(n//2):
      p *= a[i]
      q *= a[n//2+i] 

    if n%2 == 0:
      r = p*q
    else:
      r = p*q*a[-1]  
  
    if r <= 10**(18):
      print(r)
    else:
      print(-1)