stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#pragma region

#include <algorithm>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <vector>

typedef long long ll;

#define rep(i, a, n) for (long long i = a; i <= n; i++)

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

using namespace std;

#pragma endregion

int main() {

    IO;

    ll ans = 1;

    ll n;

    cin >> n;

    int flag = 0;

    while (n--) {

        ll x;

        cin >> x;

        if (!x) {

            cout << "0\n";

            return 0;

        }

        if (ll(1e18) / ans >= x)

            ans *= x;

        else

            flag = 1;

    }

    if (flag)

        cout << "-1\n";

    else

        cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.288374685661789x):
#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)?puts("0"):((flag)? puts("-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.160932016067391x):
#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)?puts("0"):((flag)? puts("-1") :printf("%lld \n", prod));

  return 0;

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

using namespace std;

long long x;

__int128 ans=1; 

long long a[100005];

void print(__int128 x)

{

	if (!x) return ;

	if (x < 0) putchar('-'),x = -x;

	print(x / 10);

	putchar(x % 10 + '0');

}

int main()

{

	int flag=1;

	int n;cin>>n;

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

	{

		cin>>a[i];

		if(a[i]==0)

		{

			flag=0;

		}

	}

	if(!flag)

	{

		cout<<"0";return 0;

	}

	else

	{

		int flag1=1;

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

		{

			ans*=a[i];

			if(ans>1000000000000000000LL)

			{

				flag1=0;

			}

		}

		if(!flag1)

		{

			cout<<"-1";return 0;

		}

		else

		{

			print(ans);

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.243421145216673x):
#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)?puts("0"):((flag)? puts("-1") :printf("%lld \n", prod));

  return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

const unsigned long long maxn=1e18;

const int maxx=1e5+10;

int main()

{

	unsigned long long a[maxx],ans=1;

	int n;

	cin>>n;

	int flag=0;

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

    {

    	cin>>a[i];

    	if(a[i]==0)

    	 flag=1;

    }

    if(flag)

    {

    	cout<<0<<endl;

    	return 0;

	}

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

    {

        if(a[i]<=maxn/ans) 

		 ans*=a[i];

        else

        {

            cout<<-1<<endl;

            return 0;

        }

    }

    cout<<ans<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3127773164129675x):
 #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) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#pragma region

#include <algorithm>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <vector>

typedef long long ll;

#define rep(i, a, n) for (long long i = a; i <= n; i++)

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

using namespace std;

#pragma endregion

int main() {

    IO;

    ll ans = 1;

    ll n;

    cin >> n;

    int flag = 0;

    while (n--) {

        ll x;

        cin >> x;

        if (!x) {

            cout << "0\n";

            return 0;

        }

        if (ll(1e18) / ans >= x)

            ans *= x;

        else

            flag = 1;

    }

    if (flag)

        cout << "-1\n";

    else

        cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.288548245973557x):
 #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) ? puts("0") : ((flag) ? puts("-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.161101393810641x):
 #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) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));

  return 0;

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

using namespace std;

long long x;

__int128 ans=1; 

long long a[100005];

void print(__int128 x)

{

	if (!x) return ;

	if (x < 0) putchar('-'),x = -x;

	print(x / 10);

	putchar(x % 10 + '0');

}

int main()

{

	int flag=1;

	int n;cin>>n;

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

	{

		cin>>a[i];

		if(a[i]==0)

		{

			flag=0;

		}

	}

	if(!flag)

	{

		cout<<"0";return 0;

	}

	else

	{

		int flag1=1;

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

		{

			ans*=a[i];

			if(ans>1000000000000000000LL)

			{

				flag1=0;

			}

		}

		if(!flag1)

		{

			cout<<"-1";return 0;

		}

		else

		{

			print(ans);

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.243593230188481x):
 #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) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));

  return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

const unsigned long long maxn=1e18;

const int maxx=1e5+10;

int main()

{

	unsigned long long a[maxx],ans=1;

	int n;

	cin>>n;

	int flag=0;

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

    {

    	cin>>a[i];

    	if(a[i]==0)

    	 flag=1;

    }

    if(flag)

    {

    	cout<<0<<endl;

    	return 0;

	}

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

    {

        if(a[i]<=maxn/ans) 

		 ans*=a[i];

        else

        {

            cout<<-1<<endl;

            return 0;

        }

    }

    cout<<ans<<endl;

    return 0;

}

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



int main() {

  int n;

  scanf("%d", &n);

  

  long long int array[n], max = 1e18, product = 1, mark = 0, zero = 0;

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

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

    mark = (array[i] > max) ? 1 : mark;

    product *= array[i];

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

  }



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

  return 0;

}
// Slower C++ solution:
#pragma region

#include <algorithm>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <vector>

typedef long long ll;

#define rep(i, a, n) for (long long i = a; i <= n; i++)

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

using namespace std;

#pragma endregion

int main() {

    IO;

    ll ans = 1;

    ll n;

    cin >> n;

    int flag = 0;

    while (n--) {

        ll x;

        cin >> x;

        if (!x) {

            cout << "0\n";

            return 0;

        }

        if (ll(1e18) / ans >= x)

            ans *= x;

        else

            flag = 1;

    }

    if (flag)

        cout << "-1\n";

    else

        cout << ans << endl;

}

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



int main() {

  int n;

  scanf("%d", &n);

  

  long long int array[n], max = 1e18, product = 1, mark = 0, zero = 0;

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

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

    mark = (array[i] > max) ? 1 : mark;

    product *= array[i];

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

  }



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

  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.161101393810641x):
#include <stdio.h>



int main() {

  int n;

  scanf("%d", &n);

  

  long long int array[n], max = 1e18, product = 1, mark = 0, zero = 0;

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

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

    mark = (array[i] > max) ? 1 : mark;

    product *= array[i];

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

  }



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

  return 0;

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

using namespace std;

long long x;

__int128 ans=1; 

long long a[100005];

void print(__int128 x)

{

	if (!x) return ;

	if (x < 0) putchar('-'),x = -x;

	print(x / 10);

	putchar(x % 10 + '0');

}

int main()

{

	int flag=1;

	int n;cin>>n;

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

	{

		cin>>a[i];

		if(a[i]==0)

		{

			flag=0;

		}

	}

	if(!flag)

	{

		cout<<"0";return 0;

	}

	else

	{

		int flag1=1;

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

		{

			ans*=a[i];

			if(ans>1000000000000000000LL)

			{

				flag1=0;

			}

		}

		if(!flag1)

		{

			cout<<"-1";return 0;

		}

		else

		{

			print(ans);

		}

	}

}

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



int main() {

  int n;

  scanf("%d", &n);

  

  long long int array[n], max = 1e18, product = 1, mark = 0, zero = 0;

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

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

    mark = (array[i] > max) ? 1 : mark;

    product *= array[i];

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

  }



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

  return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

const unsigned long long maxn=1e18;

const int maxx=1e5+10;

int main()

{

	unsigned long long a[maxx],ans=1;

	int n;

	cin>>n;

	int flag=0;

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

    {

    	cin>>a[i];

    	if(a[i]==0)

    	 flag=1;

    }

    if(flag)

    {

    	cout<<0<<endl;

    	return 0;

	}

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

    {

        if(a[i]<=maxn/ans) 

		 ans*=a[i];

        else

        {

            cout<<-1<<endl;

            return 0;

        }

    }

    cout<<ans<<endl;

    return 0;

}

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



int main()

{

	int t;

	long long int a, max=1e18,flag=0,zero=0,prod=1;

	

	scanf("%d",&t);

	

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

	{

		scanf("%lld",&a);

		flag=(a>max) ? 1:flag;

		prod*=a;

		a!=0 ? max=max/a : zero=1;

	}

	if (zero==1)

	{

		printf("0\n");

	}

	

	else if (flag == 1)

	{

		printf("-1\n");

	}

	else

	{

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

	}

	

	return 0;

}
// Slower C++ solution:
#pragma region

#include <algorithm>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <vector>

typedef long long ll;

#define rep(i, a, n) for (long long i = a; i <= n; i++)

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

using namespace std;

#pragma endregion

int main() {

    IO;

    ll ans = 1;

    ll n;

    cin >> n;

    int flag = 0;

    while (n--) {

        ll x;

        cin >> x;

        if (!x) {

            cout << "0\n";

            return 0;

        }

        if (ll(1e18) / ans >= x)

            ans *= x;

        else

            flag = 1;

    }

    if (flag)

        cout << "-1\n";

    else

        cout << ans << endl;

}

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



int main()

{

	int t;

	long long int a, max=1e18,flag=0,zero=0,prod=1;

	

	scanf("%d",&t);

	

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

	{

		scanf("%lld",&a);

		flag=(a>max) ? 1:flag;

		prod*=a;

		a!=0 ? max=max/a : zero=1;

	}

	if (zero==1)

	{

		printf("0\n");

	}

	

	else if (flag == 1)

	{

		printf("-1\n");

	}

	else

	{

		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.16049605891513x):
#include<stdio.h>



int main()

{

	int t;

	long long int a, max=1e18,flag=0,zero=0,prod=1;

	

	scanf("%d",&t);

	

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

	{

		scanf("%lld",&a);

		flag=(a>max) ? 1:flag;

		prod*=a;

		a!=0 ? max=max/a : zero=1;

	}

	if (zero==1)

	{

		printf("0\n");

	}

	

	else if (flag == 1)

	{

		printf("-1\n");

	}

	else

	{

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

	}

	

	return 0;

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

using namespace std;

long long x;

__int128 ans=1; 

long long a[100005];

void print(__int128 x)

{

	if (!x) return ;

	if (x < 0) putchar('-'),x = -x;

	print(x / 10);

	putchar(x % 10 + '0');

}

int main()

{

	int flag=1;

	int n;cin>>n;

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

	{

		cin>>a[i];

		if(a[i]==0)

		{

			flag=0;

		}

	}

	if(!flag)

	{

		cout<<"0";return 0;

	}

	else

	{

		int flag1=1;

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

		{

			ans*=a[i];

			if(ans>1000000000000000000LL)

			{

				flag1=0;

			}

		}

		if(!flag1)

		{

			cout<<"-1";return 0;

		}

		else

		{

			print(ans);

		}

	}

}

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



int main()

{

	int t;

	long long int a, max=1e18,flag=0,zero=0,prod=1;

	

	scanf("%d",&t);

	

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

	{

		scanf("%lld",&a);

		flag=(a>max) ? 1:flag;

		prod*=a;

		a!=0 ? max=max/a : zero=1;

	}

	if (zero==1)

	{

		printf("0\n");

	}

	

	else if (flag == 1)

	{

		printf("-1\n");

	}

	else

	{

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

	}

	

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

const unsigned long long maxn=1e18;

const int maxx=1e5+10;

int main()

{

	unsigned long long a[maxx],ans=1;

	int n;

	cin>>n;

	int flag=0;

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

    {

    	cin>>a[i];

    	if(a[i]==0)

    	 flag=1;

    }

    if(flag)

    {

    	cout<<0<<endl;

    	return 0;

	}

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

    {

        if(a[i]<=maxn/ans) 

		 ans*=a[i];

        else

        {

            cout<<-1<<endl;

            return 0;

        }

    }

    cout<<ans<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3127773164129675x):
#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) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));

	

	return 0;

}
// Slower C++ solution:
#pragma region

#include <algorithm>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <stack>

#include <string>

#include <vector>

typedef long long ll;

#define rep(i, a, n) for (long long i = a; i <= n; i++)

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

using namespace std;

#pragma endregion

int main() {

    IO;

    ll ans = 1;

    ll n;

    cin >> n;

    int flag = 0;

    while (n--) {

        ll x;

        cin >> x;

        if (!x) {

            cout << "0\n";

            return 0;

        }

        if (ll(1e18) / ans >= x)

            ans *= x;

        else

            flag = 1;

    }

    if (flag)

        cout << "-1\n";

    else

        cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.288548245973557x):
#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) ? puts("0") : ((flag) ? puts("-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.161101393810641x):
#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) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));

	

	return 0;

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

using namespace std;

long long x;

__int128 ans=1; 

long long a[100005];

void print(__int128 x)

{

	if (!x) return ;

	if (x < 0) putchar('-'),x = -x;

	print(x / 10);

	putchar(x % 10 + '0');

}

int main()

{

	int flag=1;

	int n;cin>>n;

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

	{

		cin>>a[i];

		if(a[i]==0)

		{

			flag=0;

		}

	}

	if(!flag)

	{

		cout<<"0";return 0;

	}

	else

	{

		int flag1=1;

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

		{

			ans*=a[i];

			if(ans>1000000000000000000LL)

			{

				flag1=0;

			}

		}

		if(!flag1)

		{

			cout<<"-1";return 0;

		}

		else

		{

			print(ans);

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.243593230188481x):
#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) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));

	

	return 0;

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

#include <iostream>

#include <algorithm>

#include <vector>

#include <string>

#include <string.h>

using namespace std;

 

int main(){

   long long int result;

  int n;

 long long int a[100000]={};

n=0;

 

result=1;

    cin >> n;

 

 

 

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

      	

        cin >> a[i];

      	if(1000000000000000000/result<a[i])result=-1;

      	if(result!=-1)result*=a[i];

      	if(result>1000000000000000000)result=-1;

      	if(a[i]==0){result=0;break;}

    }

	cout << result <<endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7722116552293075x):
#include <string>

#include <iostream>

#include <vector>

#include <string>

#include <utility>

#include <algorithm>

#include <math.h>

 

using namespace std;

int main() {

    cin.tie(0);

       ios::sync_with_stdio(false);

 

    int x;

    unsigned long long y = 1;

    int z = -1;

    unsigned long long p = 1000000000000000000;

    cin >> x;

    vector<unsigned long long> vec(x);

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

      cin >> vec.at(i);

    }

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

      if(vec.at(i)==0){

        cout << 0;

        return 0;

      }else if(vec.at(i)>p){

        cout << z;

        return 0;

      }

    }

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

     

      if(y>p/vec.at(i)){

        cout << z;

        return 0;

      }



y = y*vec.at(i);



    }

  

    

    if(y > p){

      cout << z;

    }else{

      cout << y;

    }

  

   return 0;

  

}