#include <bits/stdc++.h>
using namespace std;
// 6 2 <2 1 <1 3 >3
const int mx=1000000007;
void solve(){
	int n;cin>>n;
	vector<int> ar(n);
	for (int&v:ar)cin>>v;
	set<int> s;
	int prev=mx;
	for (int&a:ar){
		s.insert(a);
		if(prev!=mx){
			int cmin=min(prev,a),cmax=max(prev,a);
			auto it1=s.find(cmin);
			auto it2=s.find(cmax);
			if (it1!=it2&&next(it1)!=it2) {
				// cout<<prev<<"AAA"<<a<<endl;
				cout<<"NO\n";
				return;
			}
		}
		prev=a;
	}
	cout<<"YES\n";
}
int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);
	int t;cin>>t;
	while (t--) solve();
	return 0;
}