Chef and rotation

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

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t ; cin>>t;
while(t–)
{
long long n,cnt=0,ans=0,k=1;cin>>n;
long long a[n];
for (ll i=0;i<n; i++) {cin>>a[i];}
for(;1;)
{
for (ll i=0 ; i < n; i++)
{
if(a[i]==k)k++;

    }
    cnt++;
    if(ans==k)break;
    ans=k;
    }
    cout<<cnt-1<<endl;

}

return 0;

}

plz someone explain where is the wrong,