#include <bits/stdc++.h>

using namespace std;

int main() {

int t;

cin>>t;

while(t–){

int n;

cin>>n;

vectora(n);

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

cin>>a[i];

}

int o=0,z=0;

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

if(a[i]==1){

o++;

}

else if(a[i]==0){

z++;

}

}

if(n%2==1 || o==0 || z==0 || o>z){

cout<<-1<<endl;

}

else if(o==z){

cout<<0<<endl;

}

else if(o<z){

cout<<(z-o)/2<<endl;

}

}

return 0;

}

my approach is when the number of elements is odd or array contains only zero or only ones or number of ones is greater than number of zeroes simply return -1

when count of ones equal to count of zeroes return it 0

when count of zeroes is greater than count of ones we will return as (count of zeroes-count of ones)/2

and the result showing as wrong answer

what’s the problem?