Help in solving NONNEGPROD (948 difficulty)

#include <bits/stdc++.h>
using namespace std;

int main() {
	int t ;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int arr[n];
	    int count=1, z = 0;
	    for(int i=0;i<n;i++)
	    {
	        cin>>arr[i];
	        count=count*arr[i];
	        
	    }
	    if(count >= 0)
	    {
	        cout<<"0"<<endl;
	    }
	    else{
	        cout<<"1"<<endl;
	    }
	}
	return 0;


}

I tried this same using long long int too but one test case is failing WA. I know of the other approach to count the number of negs and zeros, I need to know why this brute force is not working.

The range of long long in C++ is approximately -9 * 1018 to 9 * 1018, Which in this case is way to small. For example, if we multiply only 10 values where each value is 1000. We get 1030, which causes an overflow. So according to constraints the range of the total product is between -1 * 1030000 to 1030000, which is very large.

@harshith05
plzz refer my c++ code for better understanding for the logic

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	   int n,p=1;
	   cin>>n;
	   int a[n];
	   int cnt=0,cnt1=0;
	   for(int i=0;i<n;i++)
	   {
	       cin>>a[i];
	        if(a[i]<0)
	        cnt++;
	        else if(a[i]==0)
	        cnt1++;
	       

	   }
	   
	   if(cnt1==0&&cnt%2) cout<<1<<endl;
	   else cout<<0<<endl;
	   
	   
	   
	}
	return 0;
}