#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define setval(arr,v) memset(arr,v,sizeof(arr));
#define int long long int
#define mod 1000000007
#define v vector
#define umap unordered_map
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define fi first
#define se second
#define INF 1000000000000000
using namespace std;

void solve()
{	
	int n;
	cin>>n;
	int b[n];
	set<int> s;
	for (int i = 0; i < n; ++i)
	{
		cin>>b[i];
		
	}
	s.insert(b[0]);
	for (int i = 1; i < n; ++i)
	{
		s.insert(b[i]);
		auto it1 = s.find(max(b[i],b[i-1]));
		auto it = s.find(min(b[i],b[i-1]));
		if(it == it1)
		{
			continue;
		}
		it++;
		if(it == it1)
			continue;
		cout<<"NO\n";
		return;
	}
	cout<<"YES\n";


}
 
 
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
 
}