#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pii pair<int,int>
#define all(v) v.B,v.E
#define vi vector<int>
#define vii vector<pair<int,int>>
#define mod2 998244353
#define mod 1000000007

int32_t main()
{
    ll t = 1;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        for(int i = 0; i<n; i++)
        {
            cin>>a[i];
        }
        set<int> s;
        s.insert(a[0]);
        bool flag = true;
        for(int i = 1; i<n; i++)
        {
            s.insert(a[i]);
            auto it = s.find(a[i-1]);
            if(a[i]>a[i-1])
            {
                it++;
                if(*it!=a[i])
                {
                    flag =false;
                    break;
                }
            }
            else if(a[i]<a[i-1])
            {
                it--;
                if(*it!=a[i])
                {
                    flag = false;
                    break;
                }
            }
        }
        if(flag) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}