#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back

const int MAX_N = 1e7+ 2;
const ll mod = 1e9 + 7;
const ll INF = (ll)(INT_MAX)*(INT_MAX);
const ll INF_ = -(ll)(INT_MAX)*(INT_MAX);

void solve() {
    ll n;
    cin>>n;
    ll* arr = new ll[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    ll m1 = INF, m2 = INF_;
    set<ll> s;
    for(int i=0; i<n; i++)
    {
        if(arr[i] < m2 || arr[i] > m1)
        {
            cout<<"NO"<<endl;
            return;
        }
        else
        {
            s.insert(arr[i]);
            auto it1 = s.lower_bound(arr[i]);
            auto it2 = s.upper_bound(arr[i]);
            if(it1 == s.begin()) m2 = INF_;
            else m2 = *(--it1);
            if(it2 == s.end()) m1 = INF;
            else m1 = *it2;
        }
    }
    cout<<"YES"<<endl;
}

int main() {
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case " << t  << ": ";
        solve();
    }
}
