stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



using ll = long long;

using ull = unsigned long long;

using ld = long double;



#define MOD 1000000007LL



#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)

#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)

#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)

#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)

#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)

#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)

#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)

#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)

#define iter(i, it) for(auto &(i): (it))



template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {

    cout << "(" << m.first << ", " << m.second << ")";

    return s;

}

template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {

    ll c = 0;

    cout << "{ ";

    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");

    cout << "}";

    return s;

}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {

    cout << "{ ";

    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");

    cout << "}";

    return s;

}

template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {

    ll c = 0;

    cout << "{ ";

    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");

    cout << "}";

    return s;

}



int main(void) {

    ll N;

    ll ans = 1;

    bool flag = false;

    bool zero = false;

    cin >> N;

    rep(i, N) {

        ll prev;

        ll temp;

        cin >> temp;

        prev = ans;

        ans *= temp;

        if(prev > ans || ans > 1000000000000000000 || temp > 1000000000000000000 || (temp > 1 && temp >= 1000000000000000000)) {

            flag = true;

        }

        if(temp == 0) zero = true;

    }

    if(zero) cout << 0 << endl;

    else if(flag) cout << -1 << endl;

    else cout << ans << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>



int main(void){

    int i;

    int N;

    long m = 1;

    long a[100000];

    int ng = 0;

    int zero = 0;



    scanf("%d", &N);



    for(i = 0;i < N;i++){

        long prv;

        scanf("%ld", &a[i]);

        prv = m;

        m *= a[i];

        if(prv > m || m > 1000000000000000000) ng = 1;

        if(a[i] == 0) zero = 1;

    }



    if(zero) puts("0");

    else if(ng) puts("-1");

    else printf("%ld", m);



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



using ll = long long;

using ull = unsigned long long;

using ld = long double;



#define MOD 1000000007LL



#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)

#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)

#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)

#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)

#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)

#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)

#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)

#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)

#define iter(i, it) for(auto &(i): (it))



template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {

    cout << "(" << m.first << ", " << m.second << ")";

    return s;

}

template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {

    ll c = 0;

    cout << "{ ";

    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");

    cout << "}";

    return s;

}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {

    cout << "{ ";

    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");

    cout << "}";

    return s;

}

template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {

    ll c = 0;

    cout << "{ ";

    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");

    cout << "}";

    return s;

}



int main(void) {

    ll N;

    ll ans = 1;

    bool flag = false;

    bool zero = false;

    cin >> N;

    rep(i, N) {

        ll prev;

        ll temp;

        cin >> temp;

        prev = ans;

        ans *= temp;

        if(prev > ans || ans > 1000000000000000000) {

            flag = true;

        }

        if(temp == 0) zero = true;

    }

    if(zero) cout << 0 << endl;

    else if(flag) cout << -1 << endl;

    else cout << ans << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>



int main(void){

    int i;

    int N;

    long m = 1;

    long a[100000];

    int ng = 0;

    int zero = 0;



    scanf("%d", &N);



    for(i = 0;i < N;i++){

        long prv;

        scanf("%ld", &a[i]);

        prv = m;

        m *= a[i];

        if(prv > m || m > 1000000000000000000) ng = 1;

        if(a[i] == 0) zero = 1;

    }



    if(zero) puts("0");

    else if(ng) puts("-1");

    else printf("%ld", m);



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

	long long n;

	cin>>n;

	long long a[n];

	for(long long i=0;i<n;i++)

	cin>>a[i];

	long long sum=1,jilu=0;

	for(long long i=0;i<n;i++)

	{

		if(a[i]==0)

		jilu=1;

	}

	if(jilu==1)

	cout<<0;

	else

	{

	for(long long i=0;i<n;i++)

	{

		if((1000000000000000000/a[i])<sum)

		{

			sum=-1;

			break;

		}

	sum*=a[i];

	}

	cout<<sum;

		}

} 

// Optimized solution to the same problem (faster):
#include<stdio.h>

 

int main(){

  long long n,ans=1;

  scanf("%lld",&n);

  long long arr[n+5],maks=1000000000000000000;

  for(long long i=1;i<=n;i++){

      scanf("%lld",&arr[i]);}

  

  for(int i=1;i<=n;i++){

    if(arr[i]==0){

        printf("0");

        return 0;

    }

  }

  

  for(long long i=1;i<=n;i++){

    if(maks/ans<arr[i]){

        printf("-1");

        return 0;

    }

    

    ans*=arr[i];

  }

  

  printf("%lld",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
 #include<bits/stdc++.h>

#include<iostream>

#include<algorithm>

#include<cstring>

#include<cstdio>

#include<cmath>

#define ll  long long

#define ull unsigned long long

#define IO ios::sync_with_stdio(false), cin.tie(0)

#define endl '\n'

#define main() int main()

#define ff1(i,n) for(int i=1;i<=n;++i)

#define ff0(i,n) for(int i=0;i<n;++i)

#define pi acos(-1.0)

#define ms(a, x) memset(a, x, sizeof(a))

#define lowbit(x) ((x)&(-(x)))

#define pb push_back

#define binarycount __builtin_popcount(x)

#define tr t[root]

#define lson t[root << 1]

#define rson t[root << 1 | 1]

#define fir first

#define sec second

#define debug(x) cout<<x<<'\n'

#define sa(a) scanf("%d", &a)

#define sab(a, b) scanf("%d%d", &a, &b)

#define pa(a) printf("%d",a)

#define pab(a,b) printf("%d%d",a,b)

#define pii pair<int,int>

using namespace std;



#define maxn 200005

const int inf = 0x3f3f3f3f;

const int mod = 1e9+7;

const double eps = 1e-8;

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

ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}

ll powmod(ll a,ll b){

    ll ans = 1, pow = a%mod;

    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }

    return ans%mod;

}

ull a[maxn];

const ll maxx=1e18;

bool judge(ull a, ull b) {

    if (maxx/a<b) {

        return true;

    }

    return false;

}

main() {

    int n;

    cin>>n;

    int f=1;

    for (int i=0;i<n;i++) {

        cin>>a[i];

        if (a[i]==0) f=0;

    }

    if(f==0){

    	cout<<0<<endl;

    	return 0;

	}

    ll ans=1;

    for (int i=0;i<n;i++) {

        if (judge(ans,a[i])) {

            cout<<"-1"<<endl;

            return 0;

        }

        ans*=a[i];

    }

    cout<<ans<<endl;





}

 

// Optimized solution to the same problem (faster):
#include<stdio.h>

 

int main(){

  long long n,ans=1;

  scanf("%lld",&n);

  long long arr[n+5],maks=1000000000000000000;

  for(long long i=1;i<=n;i++){

      scanf("%lld",&arr[i]);}

  

  for(int i=1;i<=n;i++){

    if(arr[i]==0){

        printf("0");

        return 0;

    }

  }

  

  for(long long i=1;i<=n;i++){

    if(maks/ans<arr[i]){

        printf("-1");

        return 0;

    }

    

    ans*=arr[i];

  }

  

  printf("%lld",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define IO ios::sync_with_stdio(0), cin.tie(0)

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 5;

const ll inf = 1e18;

int main() {

    IO;

    int n;

    ll ans = 1;

    cin >> n;

    bool flag = true;

    for (int i = 0; i < n; ++i) {

        ll x;

        cin >> x;

        if (x == 0) {

            ans = 0;

            flag = true;

        }

        else if (ULLONG_MAX / ans < x || x * ans > inf) {

            flag = false;

            //cout << ans << " " << ULLONG_MAX << " " << ULLONG_MAX / ans << endl;

        }

        if (flag) ans *= x;

        // cout << ans << endl;

    }

    if (flag)

        cout << ans << endl;

    else {

        cout << -1 << endl;

    }



    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

 

int main(){

  long long n,ans=1;

  scanf("%lld",&n);

  long long arr[n+5],maks=1000000000000000000;

  for(long long i=1;i<=n;i++){

      scanf("%lld",&arr[i]);}

  

  for(int i=1;i<=n;i++){

    if(arr[i]==0){

        printf("0");

        return 0;

    }

  }

  

  for(long long i=1;i<=n;i++){

    if(maks/ans<arr[i]){

        printf("-1");

        return 0;

    }

    

    ans*=arr[i];

  }

  

  printf("%lld",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

long long int n,a,b,f;

vector<long long int>v;

int main()

{

    cin>>n;

    b=1,f=0;

    for(int i=0; i<n; i++)

    {

        cin>>a;

        if(a==0)

            f=1;

        v.push_back(a);

    }

    if(f)

        return cout<<0<<endl,0;

    for(int i=0; i<n; i++)

    {

        if(b / 1e18 * v[i] <= 1.00)

            b*=v[i];

        else

            return cout<<-1<<endl,0;

    }



    if (b <= 1000000000000000000LL)

        cout<<b;

    else

        cout << -1;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

 

int main(){

  long long n,ans=1;

  scanf("%lld",&n);

  long long arr[n+5],maks=1000000000000000000;

  for(long long i=1;i<=n;i++){

      scanf("%lld",&arr[i]);}

  

  for(int i=1;i<=n;i++){

    if(arr[i]==0){

        printf("0");

        return 0;

    }

  }

  

  for(long long i=1;i<=n;i++){

    if(maks/ans<arr[i]){

        printf("-1");

        return 0;

    }

    

    ans*=arr[i];

  }

  

  printf("%lld",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



bool overflow(long long a, long long b)

{

    if (a <= (1000000000000000000 / b)) return 0;

    return 1;

}



int main()

{

    long long n;

    cin >> n;

    vector<long long> v(n);

    bool f = 1;

    for (int i = 0; i < n; i++){

        cin >> v[i];

        if (v[i] == 0) f = 0;

    }

    if (f == 0){

        cout << 0 << endl;

        return 0;

    }

    f = 0;

    long long mul = 1LL;

    for (int i = 0; i < n; i++){

        if (overflow(mul, v[i])){

            f = 1;

            break;

        }

        mul *= v[i];

    }

    if (overflow(mul, 1LL)) f = 1;

    if (f) puts("-1");

    else cout << mul << endl;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

 

int main(){

  long long n,ans=1;

  scanf("%lld",&n);

  long long arr[n+5],maks=1000000000000000000;

  for(long long i=1;i<=n;i++){

      scanf("%lld",&arr[i]);}

  

  for(int i=1;i<=n;i++){

    if(arr[i]==0){

        printf("0");

        return 0;

    }

  }

  

  for(long long i=1;i<=n;i++){

    if(maks/ans<arr[i]){

        printf("-1");

        return 0;

    }

    

    ans*=arr[i];

  }

  

  printf("%lld",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>



int main(){



    int i;

    int brpkali;

    long long hasil=1;

    unsigned long long Data = 1000000000000000000u;

    scanf("%d", &brpkali);

    long long arr[1000000]={};

    for(i=0;i<brpkali;i++)

    {

        scanf("%lld", &arr[i]);

    }

    for(i=0;i<brpkali;i++)

    {

    

        if (arr[i]==0){

            printf("0\n");

            return 0;

        }

    }

    for(i=0;i<brpkali;i++)

    {

        if (arr[i]<=(Data/hasil))

        {   

            hasil*=arr[i];

            

        }

        else

        {

            printf("-1\n");

            return 0;

        }  

    }

    printf("%lld\n", hasil);



    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

 

int main(){

  long long n,ans=1;

  scanf("%lld",&n);

  long long arr[n+5],maks=1000000000000000000;

  for(long long i=1;i<=n;i++){

      scanf("%lld",&arr[i]);}

  

  for(int i=1;i<=n;i++){

    if(arr[i]==0){

        printf("0");

        return 0;

    }

  }

  

  for(long long i=1;i<=n;i++){

    if(maks/ans<arr[i]){

        printf("-1");

        return 0;

    }

    

    ans*=arr[i];

  }

  

  printf("%lld",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



int n;

long long ans=1;

bool zero=false, minuss=false;



int main(){

	cin >> n;

	for (int i=0;i<n;i++){

		long long a;

		cin >> a;

		if (a==0) zero=true;

		else if (ans<=1000000000000000000/a) ans*=a;

		else minuss=true;

	}

	if (zero) cout << 0 << "\n";

	else if (minuss) cout << -1 << "\n";

	else cout << ans << "\n";

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

 

int main(){

  long long n,ans=1;

  scanf("%lld",&n);

  long long arr[n+5],maks=1000000000000000000;

  for(long long i=1;i<=n;i++){

      scanf("%lld",&arr[i]);}

  

  for(int i=1;i<=n;i++){

    if(arr[i]==0){

        printf("0");

        return 0;

    }

  }

  

  for(long long i=1;i<=n;i++){

    if(maks/ans<arr[i]){

        printf("-1");

        return 0;

    }

    

    ans*=arr[i];

  }

  

  printf("%lld",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h> 

using namespace std; 

 

#define ll long long

#define endl "\n"

#define mod 1000000007

 

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll n;

    cin>>n;

    ll a[n];

    bool hasZero = false;

    long double logs = 0;

    for(int i = 0; i < n; i++)

    {

        cin>>a[i];

        logs += log10(a[i]);

        if(a[i] == 0)

            hasZero = true;

    }

    if(hasZero)

    {

        cout<<0<<endl;

        return 0;

    }

    if(logs > 18)

    {

        cout<<"-1\n";

        return 0;

    }

    ll sum = 1;

    for(int i = 0; i < n; i++)

    {

        sum *= a[i];

        if(sum > 1000000000000000000)

        {

            cout<<"-1\n";

            return 0;

        }

    }

    cout<<sum<<endl;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

long long a [100010];

int main ()

{

int n;

scanf("%d",&n);

for(int i=0;i<n;i++) scanf("%lld",&a[i]);

int zero =0;

for(int i=0;i<n;i++)if(a[i]==0) zero ++;

if(zero >0){

// a[i] contains 0

printf("0\n");

return 0;

}

long long prod =1;

for(int i=0;i<n;i++){

if(a[i ] <=1000000000000000000/ prod ){

// This condition is equivalent to prod*a[i] <=10ˆ18

prod *=a[i];

}else{

printf("-1\n");

return 0;

}

}

printf("%lld\n",prod );

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream> 

#include<algorithm>

#include<map>

#include <cstdlib>

using namespace std;



int main(){

    int n;

    cin>>n;

    long long r=1,a[100005];

    for(int i=0;i<n;i++){

    	cin>>a[i];

	}

	sort(a,a+n);

	if(a[0]==0){

		cout<<0;

		return 0;

	}

	for(int i=n-1;i>=0;i--){

		if(1000000000000000000/a[i]>=r) r*=a[i];

		else{

			cout<<-1;

			return 0;

		}

	}

	cout<<r;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main (){

    long long int N;

    long long int total=1;

    

    scanf("%lld",&N);

    long long int A[N]; 

    

    for(int i=0;i<N;i++){

        scanf("%lld", &A[i]);

    }

    for(int j=0;j<N;j++){

        if(A[j] == 0){  

            printf("0"); 

            return 0;

        }

    }

    for(int k=0;k<N;k++){

        if(A[k]<=1000000000000000000/total){

            total = total*A[k];

            

        } else {

            printf("-1");

            return 0;

        }

    }

    printf("%lld", total);

    

    

return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<cstring>

using namespace std;

typedef long long  ll;

const long long maxt=1e18;

int main()

{

	ll n,a[100005],b,ans=1;

	cin>>n;

	for(int i=0;i<n;i++)

	{

		cin>>a[i];

		if(a[i]==0)

		{

			cout<<0;

			return 0;

		}

	}

	for(int i=0;i<n;i++)

	{

		if((maxt/ans)<a[i])

		{

			cout<<-1;

			return 0;

		}

		ans*=a[i];

		

	}

	cout<<ans;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main (){

    long long int N;

    long long int total=1;

    

    scanf("%lld",&N);

    long long int A[N]; 

    

    for(int i=0;i<N;i++){

        scanf("%lld", &A[i]);

    }

    for(int j=0;j<N;j++){

        if(A[j] == 0){  

            printf("0"); 

            return 0;

        }

    }

    for(int k=0;k<N;k++){

        if(A[k]<=1000000000000000000/total){

            total = total*A[k];

            

        } else {

            printf("-1");

            return 0;

        }

    }

    printf("%lld", total);

    

    

return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

 

const int MAXN = 2e5+2;

unsigned long long nums[MAXN];

 

const long long MAXL = 1e18;

 

bool overflow(unsigned long long a, unsigned long long b) {

    if (ULLONG_MAX / a < b) {

        return true;

    }

    unsigned long long ans = a*b;

    if (ans>MAXL) {

        return true;

    }

    return false;

}

 

int main() {

    int n;

    scanf("%d", &n);

    for (int i=0; i<n; i++) {

        scanf("%llu", &nums[i]);

        if (0==nums[i]) {

            printf("0\n");

            return 0;

        }

    }

 

    long long ans=1;

    for (int i=0; i<n; i++) {

        if (true == overflow(ans, nums[i])) {

            printf("-1\n");

            return 0;

        }

        ans *= nums[i];

    }

 

    printf("%llu", ans);

 

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main (){

    long long int N;

    long long int total=1;

    

    scanf("%lld",&N);

    long long int A[N]; 

    

    for(int i=0;i<N;i++){

        scanf("%lld", &A[i]);

    }

    for(int j=0;j<N;j++){

        if(A[j] == 0){  

            printf("0"); 

            return 0;

        }

    }

    for(int k=0;k<N;k++){

        if(A[k]<=1000000000000000000/total){

            total = total*A[k];

            

        } else {

            printf("-1");

            return 0;

        }

    }

    printf("%lld", total);

    

    

return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	long long n, a, ans=1, p, x=1000000000000000000, flag=0;

	cin>>n;

	while(n--){

		cin>>a;

		if(ans==0)

			break;

		p=x/ans;

		if(a>p){

			ans=1;

			flag=1;

		}

		else

			ans*=a;

	}

	if(ans!=0){

		if(flag)

		cout<<-1;

		else

		cout<<ans;

	}

	else

		cout<<0;

} 

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main (){

    long long int N;

    long long int total=1;

    

    scanf("%lld",&N);

    long long int A[N]; 

    

    for(int i=0;i<N;i++){

        scanf("%lld", &A[i]);

    }

    for(int j=0;j<N;j++){

        if(A[j] == 0){  

            printf("0"); 

            return 0;

        }

    }

    for(int k=0;k<N;k++){

        if(A[k]<=1000000000000000000/total){

            total = total*A[k];

            

        } else {

            printf("-1");

            return 0;

        }

    }

    printf("%lld", total);

    

    

return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
 #include<iostream>

 #include<algorithm>

 #include<cmath>

 #include<iomanip>

 #include<cstring>

 #include<cmath>

 #include<map>

 #include<vector>

 #include<sstream>

 #include<queue>

using namespace std;



typedef long long ll;

const ll maxn=1e18;

int main()

{

    long long sum=1;

    int n;

    long long mid;

    cin>>n;

    int flag=0;

    while(n--)

    {

        cin>>mid;

        if(mid==0)

        {

            flag=-1;

        cout<<"0";

        return 0;

        }

        if(maxn/sum>=mid)

        sum*=mid;

        else

        flag=1;

    }

    

    if(flag==1) cout<<"-1";

    else if(flag==-1)cout<<"0";

    else cout<<sum;

    

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main (){

    long long int N;

    long long int total=1;

    

    scanf("%lld",&N);

    long long int A[N]; 

    

    for(int i=0;i<N;i++){

        scanf("%lld", &A[i]);

    }

    for(int j=0;j<N;j++){

        if(A[j] == 0){  

            printf("0"); 

            return 0;

        }

    }

    for(int k=0;k<N;k++){

        if(A[k]<=1000000000000000000/total){

            total = total*A[k];

            

        } else {

            printf("-1");

            return 0;

        }

    }

    printf("%lld", total);

    

    

return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long int n,s=1;

    double ans=0;

    cin>>n;

    long long int a[n],c=1,i;

    for(i=0;i<n;i++){

        cin>>a[i];

        if(a[i]==0)

            c=0;

        //cout<<log10(a[i])<<endl;

        ans=ans+(log10(a[i]));

        //cout<<ans<<endl;

    }

    if(c==0)

        cout<<"0"<<endl;

    else if(ans<=18){

        for(i=0;i<n;i++)

            s=s*a[i];

        if(s<=1000000000000000000)

        cout<<s<<endl;

        else

            cout<<"-1"<<endl;

    }

    else

        cout<<"-1"<<endl;

    return 0;

}




// Optimized solution to the same problem (faster):
#include <stdio.h>

int main (){

    long long int N;

    long long int total=1;

    

    scanf("%lld",&N);

    long long int A[N]; 

    

    for(int i=0;i<N;i++){

        scanf("%lld", &A[i]);

    }

    for(int j=0;j<N;j++){

        if(A[j] == 0){  

            printf("0"); 

            return 0;

        }

    }

    for(int k=0;k<N;k++){

        if(A[k]<=1000000000000000000/total){

            total = total*A[k];

            

        } else {

            printf("-1");

            return 0;

        }

    }

    printf("%lld", total);

    

    

return 0;

}

// Fastest known solution for this problem: