Help me in solving AOCC16 problem

My issue

what is the wrong of my code

My code

// Update the code below to solve the problem

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

int main() 
{
	int t;
    cin >> t;
	
	while(t--)
	{
	    int N;
	    cin >> N;
	    int A[N];
	    for(int i=0; i < N; i++)
	    {
	        cin >> A[i];
	    }
	    int remove=0;
	    for(int i=0;i<N-1;i++){
	        if(A[i-1]==A[i+1]){
	            remove++;
	            i++;
	        }
	    }
	    cout<<N-remove<<endl;
	}
}

Learning course: Solve Programming problems using C++
Problem Link: https://www.codechef.com/learn/BC00BC20/problems/AOCC16

@rs83050583
Your logic is not right.
Plzz refer the following code for better understanding of the logic.

// Update the code below to solve the problem

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

int main() 
{
	int t;
    cin >> t;
	
	while(t--)
	{
	    int N;
	    cin >> N;
	    int A[N];
	    for(int i=0; i < N; i++)
	    {
	        cin >> A[i];
	    }
	    int cnt=0,ans=0;
	    for(int i=1;i<N;i++)
	    {
	        if(A[i]==A[i-1])
	        cnt++;
	        else
	        {
	            ans+=cnt;
	            cnt=0;
	        }
	    }
	    ans+=cnt;
	    cout<<N-ans<<endl;
	}
}