#include<bits/stdc++.h>

using namespace std;

int main()

{

```
int t;
cin>>t;
while(t-->0)
{
int flag1=0;int flag=0;
int n;cin>>n;
int a[n+1];
a[n]=0;
vector<int>v;
for(int i=0;i<n;i++)
cin>>a[i];
int c=1;int b[10000000];
int z=0;
for(int i=0;i<n;i++)
{
b[a[i]]++;
}
for(int i=0;i<n;i++)
{
if(a[i]==a[i+1])
c++;
else
{
if(c==b[a[i]])
{
v.push_back(c);
c=1;
continue;
}
else
{
flag=1;
break;
}
}
}
if(flag==1)
cout<<("No")<<"\n";
else
{
set<int>s;
for(int x:v)
s.insert(x);
int t=s.size();
int q=v.size();
if(q==t)
cout<<("Yes")<<"\n";
else
cout<<("No")<<"\n";
}
}
}
```