Language: C++

//  Copyright © 2020 Kavish Lodha. All rights reserved.
#include <bits/stdc++.h>
using namespace std;
#define vll vector<long long>
#define mll map<long long,long long>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define pb push_back
#define prll pair<long long,long long>
typedef long long ll;
typedef long double ld;
#define rep(i,a,n)   for(ll i=a; i<n; i++)
#define rrep(i,a,n)  for(ll i=n-1; i>=a; i--)
typedef map<string,ll> msl;
#define mx 100001
#define mod 1000000000000000000
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll extgcd(ll a,ll b,ll& x,ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll revrsno(ll n){
    ll k=0;
    vll z;
    while(n>0){
        z.pb(n%10);
        n/=10;
    }
    rep(i,0,z.size()) k=k*10+z[i];
    return k;
}
bool isPrime(ll n){
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
bool isPowerOfTwo(ll n) { 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}
ll powm(ll a,ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}
ll divide(ll a,ll b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}
bool mul(ll a,ll b) {
	ll d=(a*b)%mod;
	if((sqrt(d))<sqrt(a,b)) return true;
	return false;
}
 
ll add(ll a,ll b) {
	return (a % mod + b % mod) % mod;
}
ll Totfun(ll n){
    ll z=n;
    if(n%2==0){
        while(n%2==0){
            n/=2;
        }
        z/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2){
        if(isPrime(i)&&n%i==0){
          while(n%i==0){
            n/=i;
          }
        z-=z/i;  
        }
    }
    if(n>1){
        z-=z/n;
    }
    return z;
}
ll maxPrimeFactor(ll n) { 
    ll maxPrime=-1; 
    while(n%2==0){
        maxPrime=2; 
        n>>=1; 
    } 
    for (ll i=3;i<=sqrt(n);i+=2) { 
        while(n%i==0){ 
            maxPrime=i; 
            n=n/i; 
        } 
    } 
    if (n>2) maxPrime=n; 
    return maxPrime; 
} 
ll nCr(ll n,ll r){
    if(r>n||r<0) return 0;
    ll z=1;
    for(ll i=n-r+1;i<=n;i++){
        z*=i;
        z/=(i+r-n);
    }
    return z;
}
bool z=0;
/*
vll a[mx];
ll l[mx],d[mx];
void dfs(ll x,ll y){
   l[x]=1; d[x]=y;
   for(ll i:a[x])
   if(!l[i])
   dfs(i,y+1);
}
void bfs(ll x){
    queue<ll> q;
    q.push(x);
    l[x]=1;
    d[x]=0;
    while(!q.empty()){
        ll cur=q.front();
        q.pop();
        for(ll i : a[cur]){
            if(1-l[i]){
                q.push(i);
                d[i]=d[cur]+1;
                l[i]=1;
            }
        }
    }
}
*/
 /*sort(a,a+n);
    ll d=1;
    vll z;
    for(ll i=1;i<n;i++){
    if(a[i]==a[i-1]){
        d++;
    }
    else{
            z.pb(d);
            d=1;
    }
    }
    z.pb(d);*/
int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
   ll n,ans=1;
   cin>>n;
   ll a[n];
   rep(i,0,n){
       cin>>a[i];
       ans=min(ans,a[i]);
   }
   if(ans){
       ans=1;
       rep(i,0,n){
           if(mul(ans,a[i])){
               ans=-1;
               break;
           }
           ans*=a[i];
       }
   }
   cout<<ans<<"\n";
   return 0;
}

Compiler output:
a.cc: In function 'bool mul(ll, ll)':
a.cc:76:26: error: no matching function for call to 'sqrt(ll&, ll&)'
   76 |         if((sqrt(d))<sqrt(a,b)) return true;
      |                      ~~~~^~~~~
In file included from /usr/include/c++/14/valarray:605,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:2:
/usr/include/c++/14/bits/valarray_after.h:458:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Sqrt, std::_ValArray, _Tp>, _Tp> std::sqrt(const valarray<_Tp>&)'
  458 |     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, struct std::_Sqrt)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:458:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/valarray_after.h:458:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Sqrt, std::_Expr, _Dom>, typename _Dom::value_type> std::sqrt(const _Expr<_Dom1, typename _Dom1::value_type>&)'
  458 |     _DEFINE_EXPR_UNARY_FUNCTION(sqrt, struct std::_Sqrt)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:458:5: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/complex:1195:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::sqrt(const complex<_Tp>&)'
 1195 |     sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
      |     ^~~~
/usr/include/c++/14/complex:1195:5: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:114:
/usr/include/c++/14/cmath:454:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::sqrt(_Tp)'
  454 |     sqrt(_Tp __x)
      |     ^~~~
/usr/include/c++/14/cmath:454:5: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:176:1: note: candidate: 'double sqrt(double)'
  176 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:176:1: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:446:3: note: candidate: 'constexpr long double std::sqrt(long double)'
  446 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/14/cmath:446:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/cmath:442:3: note: candidate: 'constexpr float std::sqrt(float)'
  442 |   sqrt(float __x)
      |   ^~~~
/usr/include/c++/14/cmath:442:3: note:   candidate expects 1 argument, 2 provided