stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
 #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;

    

}

// Faster C++ solution for the same problem (measured speedup: 5.224458855464986x):
#include <stdio.h>



int main() {

  int a;

  scanf("%d", &a);

  long long int arr[a], max = 1e18, prod = 1, fl = 0, zero = 0;

  

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

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

    fl = (arr[i] > max) ? 1 : fl;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? puts("0") : ((fl) ? puts("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 5.267970358929974x):
#include <stdio.h>



int main() {

  int a;

  scanf("%d", &a);

  long long int arr[a], max = 1e18, prod = 1, fl = 0, zero = 0;

  

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

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

    fl = (arr[i] > max) ? 1 : fl;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? puts("0") : ((fl) ? puts("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

ll wq[100003];

int main()

{

    int g,t;

    ll re=1,lm=1e18;

    scanf("%d",&t);

    for(g=0;g<t;g++)

        scanf("%lld",&wq[g]);

    for(g=0;g<t;g++)if(!wq[g]){

        printf("0\n");

        return 0;

    }

    for(g=0;g<t;g++){

        if(wq[g]<=(lm/re))

            re*=wq[g];

        else{

            printf("-1\n");

            return 0;

        }

    }

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.160653065638909x):
#include <stdio.h>



int main() {

  int a;

  scanf("%d", &a);

  long long int arr[a], max = 1e18, prod = 1, fl = 0, zero = 0;

  

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

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

    fl = (arr[i] > max) ? 1 : fl;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? puts("0") : ((fl) ? puts("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define c 1000000000000000000

#define ll long long int

int main()

{

    ll n,i,count=1,flag=0;

    cin>>n;

    ll a[n+1];

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

    {

        cin>>a[i];

        if(a[i]==0)

            flag=1;

    }

    ll sum=a[0];

    if(flag==0) {

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

            if (a[i] <= c / sum) {

                sum=sum*a[i];

                count++;

            } else

            {

                cout<<"-1"<<endl;

                break;

            }

        }

        if(count==n)

            cout<<sum<<endl;

    }

    else

        cout<<"0"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.221096927366487x):
#include <stdio.h>



int main() {

  int a;

  scanf("%d", &a);

  long long int arr[a], max = 1e18, prod = 1, fl = 0, zero = 0;

  

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

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

    fl = (arr[i] > max) ? 1 : fl;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? puts("0") : ((fl) ? puts("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
//sppsfver - 05.08.2020

#include <bits/stdc++.h>

using namespace std;



using ll = long long;

using pll = pair <ll, ll>;



ll n, a, ans = 1;

bool flag, zero;



int main() {

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);



    cin >> n;

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

        cin >> a;

        if (a == 0) return cout << 0 << endl, 0;

        a <= 1000000000000000000/ans ? ans *= a : flag = 1;

    }

    cout << (flag ? -1 : ans) << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.287050909577769x):
#include <stdio.h>



int main() {

  int a;

  scanf("%d", &a);

  long long int arr[a], max = 1e18, prod = 1, fl = 0, zero = 0;

  

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

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

    fl = (arr[i] > max) ? 1 : fl;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? puts("0") : ((fl) ? puts("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.7545513742942545x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.740330687453229x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.623923205407295x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#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;

} 

// Faster C++ solution for the same problem (measured speedup: 4.670175538722568x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
 #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;

    

}

// Faster C++ solution for the same problem (measured speedup: 4.6806862904206135x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 4.719669025930362x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

ll wq[100003];

int main()

{

    int g,t;

    ll re=1,lm=1e18;

    scanf("%d",&t);

    for(g=0;g<t;g++)

        scanf("%lld",&wq[g]);

    for(g=0;g<t;g++)if(!wq[g]){

        printf("0\n");

        return 0;

    }

    for(g=0;g<t;g++){

        if(wq[g]<=(lm/re))

            re*=wq[g];

        else{

            printf("-1\n");

            return 0;

        }

    }

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.623521540165958x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define c 1000000000000000000

#define ll long long int

int main()

{

    ll n,i,count=1,flag=0;

    cin>>n;

    ll a[n+1];

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

    {

        cin>>a[i];

        if(a[i]==0)

            flag=1;

    }

    ll sum=a[0];

    if(flag==0) {

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

            if (a[i] <= c / sum) {

                sum=sum*a[i];

                count++;

            } else

            {

                cout<<"-1"<<endl;

                break;

            }

        }

        if(count==n)

            cout<<sum<<endl;

    }

    else

        cout<<"0"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.677674278804603x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
//sppsfver - 05.08.2020

#include <bits/stdc++.h>

using namespace std;



using ll = long long;

using pll = pair <ll, ll>;



ll n, a, ans = 1;

bool flag, zero;



int main() {

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);



    cin >> n;

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

        cin >> a;

        if (a == 0) return cout << 0 << endl, 0;

        a <= 1000000000000000000/ans ? ans *= a : flag = 1;

    }

    cout << (flag ? -1 : ans) << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.736763633104346x):
#include <stdio.h>

int main(){

	long long int a; 

	long long int number[100000];

	scanf("%lld", &a);

	for(long long int i=0; i<a; i++){

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

	}

	for(long long int i = 0; i<a; i++){

		if(number[i]==0){

			printf("0\n");

			return(0);

			

		}

	}

	long long int ans = 1;

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

		if(number[i]<= (1000000000000000000/ans) ){

			ans=ans*number[i];

		

		}else {

			printf("-1\n");

			return(0);

		}

	} printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.307276713513168x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.291402845680004x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.161462779813582x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#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;

} 

// Faster C++ solution for the same problem (measured speedup: 5.213092031918621x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
 #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;

    

}

// Faster C++ solution for the same problem (measured speedup: 5.2248246778271605x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 5.2683392280155354x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

ll wq[100003];

int main()

{

    int g,t;

    ll re=1,lm=1e18;

    scanf("%d",&t);

    for(g=0;g<t;g++)

        scanf("%lld",&wq[g]);

    for(g=0;g<t;g++)if(!wq[g]){

        printf("0\n");

        return 0;

    }

    for(g=0;g<t;g++){

        if(wq[g]<=(lm/re))

            re*=wq[g];

        else{

            printf("-1\n");

            return 0;

        }

    }

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.161014420249417x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define c 1000000000000000000

#define ll long long int

int main()

{

    ll n,i,count=1,flag=0;

    cin>>n;

    ll a[n+1];

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

    {

        cin>>a[i];

        if(a[i]==0)

            flag=1;

    }

    ll sum=a[0];

    if(flag==0) {

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

            if (a[i] <= c / sum) {

                sum=sum*a[i];

                count++;

            } else

            {

                cout<<"-1"<<endl;

                break;

            }

        }

        if(count==n)

            cout<<sum<<endl;

    }

    else

        cout<<"0"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.221462514322753x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;

  

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

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

    flag = (arr[i] > max) ? 1 : flag;

    prod *= arr[i];

    (arr[i]) ? max /= arr[i] : zero = 1;

  }



  (zero) ? printf("0") : ((flag) ? printf("-1") : printf("%lld\n", prod));

  return 0;

}