ALLDIV3(C++)

What is the problem in my solutio for ALLDIV3 problem
here it is in C++
#include <bits/stdc++.h>
using namespace std;

int main()
{
int t;
cin>>t;
for (int i=0;i<t;i++)
{
int n;
int total=0;
int counter=0;
int array[n];

    for(int p=0;p<n;p++)
    {
        cin>>array[p];
        if(array[p]%3==-1)
        {
            array[p]++;
            counter++;
            total++;
        }
        else if(array[p]%3==1)
        {
            array[p]--;
            total--;
            counter++;
        }
       
    }
   
    if(total==0)
     {
         cout<<counter<<endl;
         
     }
    else
    {
         cout<<"-1"<<endl;
    }          
           
}    

return 0;
}