Help me in solving BROKPHON problem

My issue

what is wrong in my solution

My code

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        int n;
        cin >> n;
        vector < int > nums(n);
        for (int i = 0; i < n; i++) cin >> nums[i];
        int cnt = 0;
        for (int i = 1; i < n; i++)
        {
            if (nums[i] != nums[i - 1])
            {
                if (i == 1)
                {
                    cnt++;
                }
                else
                {
                    cnt += 2;
                }
            }
        }
        cout << cnt << endl;
    }


    return 0;
}

Problem Link: Broken Telephone Practice Coding Problem

your solution will fail for cases like this
5
1 2 3 4 5
your ans will be 7 which is greater than 5 not possible
you will be counting someone twice