Help me in solving COMPRESSVD problem

My issue

why I’m getting runtime error

My code

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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n,a[n],count=1;;
	    cin>>n;
	    for(int i=0;i<n;++i){
	        cin>>a[i];
	    }
	    for(int i=0;i<n;i++){
	        if(a[i]==a[i+1]){
	            count++;
	        }
	    }
	    cout<<count<<endl;
	}
	return 0;
}

```why its showing runtime error we cannot do without checking i+1
Problem Link: https://www.codechef.com/problems/COMPRESSVD

you are creating the array without taking the input

instead of int n, arr[n], count = 0; cin>>n;
use int n, count = 0; cin>>n;int arr[n];