#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rev(v) reverse(all(v))
#define display(A) for(auto &aa:A) cout <<aa<<" ";cout <<"\n";
#define displayP(A) for(auto &aa:A) {display(aa);}
#define read(A) for(auto &aa:A) {cin>>aa;}
#define FOR(i,n) for(ll i=0;i<n;i++)
#define TTT template<typename T> 

const ll MAX = 6e5+10,INF = 1e15; ll MOD = 998244353;
TTT void c_min(T &a, const T b){if(b<=a) a = b;}
TTT void c_max(T &a, const T b){if(a<=b) a = b;}
TTT T mexp(T a, ll e) {
    T res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; } return res;
}
ll n,m,X,N,M;

void solve(ll tc=0){
	cin>>n;
	vector<ll> a(n);
	read(a);
	set<ll> s = {-INF,INF};
	s.insert(a[0]);
	auto it = next(s.begin());
	for(ll i = 1; i < n;i++){
		if(a[i]>=*prev(it)  && a[i]<=*next(it)){
			s.insert(a[i]);
			it = s.find(a[i]);
		}
		else{
			cout <<"NO\n";
			return;
		}
	}
	cout << "YES\n";
}	
 
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll T=1,tc=0; 
	cin>>T; for(;tc<T;tc++)
	solve(tc);
	return 0;
}	