Help me in solving BROKPHON problem

My issue

My code

#include <iostream>
using namespace std;

int main() {
  long long  t;
  cin>>t;
  while(t--){
     long long n;
      cin>>n;
       long long a[n];
       for(int i=0;i<n;i++)cin>>a[i];
       
     
      long long c=0;
      for(int i=1;i<n-1;i++){
          if(a[i]==a[i-1] and a[i]==a[i+1])c++;;

      }
      if(a[0]==a[1])c++;
      if(a[n-1]==a[n-2])c++;
     // cout<<c<<endl;
      cout<<n<<endl;
  }
  return 0;
}

Problem Link: BROKPHON Problem - CodeChef

include
using namespace std;

int main() {
int t;
cin>>t;
while(t–){
long long int n;
cin>>n;
long long int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int count=0;
for(int i=0;i<n;i++){
if(i>0 && i<n-1){
if(a[i]!=a[i-1] || a[i]!=a[i+1])count++;
}
}
if(a[0]!=a[1])count++;
if(a[n-1]!=a[n-2])count++;
cout<<count<<endl;

}
return 0;

}
//This should be solution. ig