Help me in solving NORMALEZ problem

My issue

I don’t know where my approach is failing.
If anyone finds any error or any test case it may fail, kindly tell.

My code

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

int main() {
	// your code goes here
	int t;
	cin >> t;
	while(t--){
	    int n;
	    cin >> n;
	    int last;
	    cin >> last;
	    
	    int count=1;
	    int ans=0;
	    for(int i=1; i<n; i++){
	        int temp;
	        cin >> temp;
	        
	        if(temp==last){
	            count++;
	        }
	        else{
	            ans += (count * (count+1))/2;
	            count=1;
	            last = temp;
	        }
	    }
	    ans += (count * (count+1))/2;
	    cout << ans << endl;
	}

}

Problem Link: Normal is Good (Easy) Practice Coding Problem