// KEDOS123

#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define all(a) a.begin(),a.end()
#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ROF(i, a, b) for (int i = b; i >= a;i--)
#define minheap(a) priority_queue <a, vector<a>, greater<a> >
#define maxheap(a) priority_queue<a> 
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define vd vector<double>
#define vs vector<string>\
#define ms(x,y) memset(x,y,sizeof(x))
#define umap unordered_map<int,int>
#define lb lower_bound
#define ub upper_bound
//#define nx cout<<"\n";
#define INF 1000000000000000000
#define inf 1000000000
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define PI 3.14159265
#define pl pair<ll,ll> 
#define int long long
#define V vector
#define CIN(x) do { \
        assert(!cin.eof()); \
        cin >> x; \
        assert(!cin.fail()); \
} while(0);
#if DEBUG
#define debug_print(...) _debug_print(__VA_ARGS__)
#define debug_printf(...) printf(__VA_ARGS__)
#define debug_print_time _debug_print_time
#else // DEBUG
#define debug_print(...)
#define debug_printf(...)
#define debug_print_time
#endif // DEBUG
 //#define MOD   
#define EPS 1e-9
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define double long double
#define f(a,b,c) for(int a=b;a<=c;a++)
#define fd(a,b,c) for(int a=b;a>=c;a--)
const int MOD = 1000000007;


typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef double ld;
typedef vector<pii> vii;

typedef tuple<ll, ll> t2;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

//global varibles
ll bb=0, vikings=0;
ll kedos=0,jai=0;
//-----------INLINE FUNC---------
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}
inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}
inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}
inline void wri(const int v) { cout << v; }
inline void wrll(const long long &v) { cout << v; }
inline void wrs(const string& s) { cout << s; }
inline void wrc(const char c) { cout << c; }

//----------Template classes-------
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<class T>
void wrv(T beg_iter, T end_iter, string separator = " ", string end_of_line = "\n") {
    for (; beg_iter != end_iter; ++beg_iter) {
        cout << *beg_iter;
        cout << separator;
    }
    cout << end_of_line;
}

template <typename TT, typename T>
void incr_m(map<TT, T> &m, TT k)
{
    if (m.find(k) == m.end()) m[k] = 0;
    m[k]++;
}
 
void llin(ll &a)
{
    CIN(a);
}
 
void llinl1(vll &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a;
        CIN(a);
        v.push_back(a);
    }
}
 
void llinl2(V<t2> &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a, b;
        CIN(a >> b);
        v.push_back(t2(a, b));
    }
}
 
void llinl3(V<t3> &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a, b, c;
        CIN(a >> b >> c);
        v.push_back(t3(a, b, c));
    }
}
 
void llinl4(V<t4> &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a, b, c, d;
        CIN(a >> b >> c >> d);
        v.push_back(t4(a, b, c, d));
    }
}
 
void llina(V<ll> &v, ll count)
{
    llinl1(v, count);
}
 
template <typename T>
void sort(V<T> &v)
{
    sort(v.begin(), v.end());
}
 
template <typename T>
void sort_reverse(V<T> &v)
{
    sort(v.begin(), v.end(), greater<T>());
}
 
t2 _ext_gcd(ll a, ll b, ll g)
{
    if (!b) return t2(1, 0);
    ll q = a / b;
    ll r = a % b;
    t2 sol = _ext_gcd(b, r, g);
    ll sx = get<0>(sol);
    ll sy = get<1>(sol);
    ll x = sy;
    ll y = sx - q * sy;
    return t2(x, y);
}
 
t2 ext_gcd(ll a, ll b)
{
    return _ext_gcd(a, b, gcd(a, b));
}
 
// x and mod must be coprime
ll mod_inv(ll x, ll mod)
{
    t2 result = ext_gcd(x, mod);
    ll ret = get<0>(result);
    while (ret < 0) ret += mod;
    ret %= mod;
    return ret;
}
 
template <typename T>
void _debug_print(T x)
{
    cout << x << " ";
}
 
void _debug_print(const t2 &x)
{
    ll x1 = get<0>(x);
    ll x2 = get<1>(x);
    cout << "(" << x1 << ", " << x2 << ") ";
}
 
void _debug_print(const t3 &x)
{
    ll x1 = get<0>(x);
    ll x2 = get<1>(x);
    ll x3 = get<2>(x);
    cout << "(" << x1 << ", " << x2 << ", " << x3 << ") ";
}
 
void _debug_print(const t4 &x)
{
    ll x1 = get<0>(x);
    ll x2 = get<1>(x);
    ll x3 = get<2>(x);
    ll x4 = get<3>(x);
    cout << "(" << x1 << ", " << x2 << ", " << x3 << ", " << x4 << ") ";
}
 
template <typename T>
void _debug_print(T xarray[], ll n)
{
    FOR (i,0, n) _debug_print(xarray[i]);
    cout << endl;
}
 
template <typename T>
void _debug_print(const V<T> &xlist)
{
    for (auto x : xlist) _debug_print(x);
    cout << endl;
}
 
template <typename T>
void _debug_print(const set<T> &xset)
{
    for (auto x : xset) _debug_print(x);
    cout << endl;
}
 
template <typename TT, typename T>
void _debug_print(const map<TT, T> &xlist)
{
    for (auto x : xlist) {
        TT k = x.first;
        T v = x.second;
        cout << "K=";
        _debug_print(k);
        cout << " V=";
        _debug_print(v);
        cout << endl;
    }
}

struct lex_compare {
    public:
    bool operator() (const pl& lhs, const pl& rhs) const {
        return (lhs.se>rhs.se);
    }
};
template<class T>
class edge{
    public:
        T a,b;
        ll x;
        edge(){
            a=NULL,b=NULL,x=-1;
        }
        edge(T a,T b,ll x){
            this->a=a,this->b=b,this->x=x;
        }
    };
    const int mod=1e9+7;
template<const int MOD>
struct modular_int{
	int x;
	static vector<int> inverse_list ;
	const static int inverse_limit;
	const static bool is_prime;
	modular_int(){
		x = 0;
	}
	template<typename T>  
	modular_int(const T z){
		x = (z%MOD);
		if (x < 0) x += MOD; 	
	}
	modular_int(const modular_int<MOD>* z){
		x = z->x;
	}
	modular_int(const modular_int<MOD>& z){
		x = z.x;
	}
	modular_int operator - (const modular_int<MOD>& m) const{
		modular_int<MOD> U;
		U.x = x - m.x;
		if (U.x < 0) U.x += MOD;
		return U;
	}
	modular_int operator + (const modular_int<MOD>& m) const{
		modular_int<MOD> U;
		U.x = x + m.x;
		if (U.x >= MOD) U.x -= MOD;
		return U;
	}
	modular_int& operator -= (const modular_int<MOD>& m){
		x -= m.x;
		if (x < 0) x += MOD;
		return *this;
	}	
	modular_int& operator += (const modular_int<MOD>& m){
		x += m.x;
		if (x >= MOD) x -= MOD;
		return *this;
	}	
	modular_int operator * (const modular_int<MOD>& m) const{
		modular_int<MOD> U;
		U.x = (x* 1ull * m.x) %MOD;
		return U;
	}
	modular_int& operator *= (const modular_int<MOD>& m){
		x = (x * 1ull * m.x)%MOD;
		return *this;
	}
	template<typename T>
	friend modular_int operator + (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) + p);
	}
	template<typename T>
	friend modular_int operator - (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) - p);
	}
	template<typename T>
	friend modular_int operator * (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) * p);
	}
	template<typename T>
	friend modular_int operator / (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) / p);
	}
 
	int value() const{
		return x;
	}
 
	modular_int operator ^ (const modular_int<MOD>& cpower) const{
		modular_int<MOD> ans;
		ans.x = 1;
		modular_int<MOD> curr(this);
		int power = cpower.x;
 
		if (curr.x <= 1){
			if (power == 0) curr.x = 1;
			return curr;
		}
		while( power > 0){
			if (power&1){
				ans *= curr;
			}
			power >>= 1;
			if (power) curr *= curr;
		}
		return ans;
	}
 
 
	modular_int operator ^ (long long power) const{
		modular_int<MOD> ans;
		ans.x = 1;
		modular_int<MOD> curr(this);
		if (curr.x <= 1){
			if (power == 0) curr.x = 1;
			return curr;
		}
		// Prime Mods
		if (power >= MOD && is_prime){
			power %= (MOD - 1);
		}
 
		while( power > 0){
			if (power&1){
				ans *= curr;
			}
			power >>= 1;
			if (power) curr *= curr;
 
		}
		return ans;
	}
	
	template<typename T>
	modular_int& operator ^= (T power) {
		modular_int<MOD> res = (*this)^power;
		x = res.x;
		return *this;
	}
 
 
	template<typename T>
	modular_int pow(T x){
		return (*this)^x;
	}
 
	
	pair<long long,long long> gcd(const int a, const int b) const {
		if (b==0) return {1,0}; 
		pair<long long,long long> c = gcd(b , a%b);
		return { c.second , c.first - (a/b)*c.second}; 
	}
 
	inline void init_inverse_list() const {
		
		vector<int>& dp = modular_int<MOD>::inverse_list;
		dp.resize(modular_int<MOD>::inverse_limit + 1);
		int n = modular_int<MOD>::inverse_limit;
		dp[0] = 1;
		if (n > 1) dp[1] = 1;
		for(int i = 2; i <= n; ++i){
			dp[i] = (dp[MOD%i] * 1ull *(MOD - MOD/i))%MOD;
		}
	
	}
	modular_int<MOD> get_inv() const {
		if (modular_int<MOD>::inverse_list.size() < modular_int<MOD>::inverse_limit + 1) init_inverse_list();
 
		if (this->x <= modular_int<MOD>::inverse_limit){
			return modular_int<MOD>::inverse_list[this->x];
		}
		pair<long long,long long> G = gcd(this->x,MOD);
		return modular_int<MOD>(G.first);
	}
	modular_int<MOD> operator - () const {
		modular_int<MOD> v(0);
		v -= (*this);
		return v;
	}
	modular_int operator / (const modular_int<MOD>& m) const{
		modular_int<MOD> U(this);
		U *= m.get_inv();
		return U;
	}
	modular_int& operator /= (const modular_int<MOD>& m){
		(*this) *= m.get_inv();
		return *this;
	}
	bool operator==(const modular_int<MOD>& m) const{
		return x == m.x;
	}
 
	bool operator < (const modular_int<MOD>& m) const {
		return x < m.x;
	}
 
 
	template<typename T>
	bool operator == (const T& m) const{
		return (*this)== (modular_int<MOD>(m));
	}
 
	template<typename T>
	bool operator < (const T& m) const {
		return x < (modular_int<MOD>(m)).x;
	}
	template<typename T>
	bool operator > (const T& m) const {
		return x > (modular_int<MOD>(m)).x;
	}
	template<typename T>
	friend bool operator == (const T& x, const modular_int<MOD>& m) {
		return (modular_int<MOD>(x)).x == m.x;
	}
	template<typename T> 
	friend bool operator < (const T& x, const modular_int<MOD>& m){
		return (modular_int<MOD>(x)).x < m.x;
	}
	template<typename T> 
	friend bool operator > (const T& x, const modular_int<MOD>& m){
		return (modular_int<MOD>(x)).x > m.x;
	}
 
	friend istream& operator >> (istream& is, modular_int<MOD>& p){
		int64_t val;
		is >> val;
		p.x = (val%MOD);
		if (p.x < 0) p.x += MOD;
		return is;
	}
	friend ostream& operator << (ostream& os, const modular_int<MOD>& p) {return os<<p.x;}
 
 
 
};
 
 
 
using mint = modular_int<mod>;
template<const int MOD>
vector<int> modular_int<MOD>::inverse_list ;
template<const int MOD>
const int modular_int<MOD>::inverse_limit = -1;
template<const int MOD>
const bool modular_int<MOD>::is_prime = true; 
// template<>   //-> useful if computing inverse fact = i_f[i-1] / i;
// const int modular_int<mod>::inverse_limit = 100000;

/*/---------------------------Graph---------------------/*/
template<typename T>
class Graph {
	int v;
	list<int> *adj;
 
public:
	Graph(int v) {
		this->v = v;
		adj = new list<int>[v];
	}
 
	void addEdge(int u, int v, bool bidir = true) {
		adj[u].push_back(v);
		if(bidir) {
			adj[v].push_back(u);
		}
	}
 
	void printAdjList() {
		for(int i=0;i<this->v;i++) {
			cout<<i<<"->";
			for(int node:adj[i]) {
				cout<<node<<", ";
			}
			cout<<endl;
		}
	}
 
	void bfs(int src) {
		queue<int> q;
		bool *visited = new bool[this->v+1]{0};
 
		q.push(src);
		visited[src] = true;
 
		while(!q.empty()) {
			int node = q.front();
			cout<<node<<" ";
			q.pop();
			for(int neighbour: adj[node]) {
				if(!visited[neighbour]) {
					q.push(neighbour);
					visited[neighbour] = true;
				}
			}
		}
 
		delete [] visited;
	}
 
 
	void bfs(int src,int dest){
     	//Traverse all the nodes of the graph
     	queue<int> q;
     	bool *visited = new bool[v+1]{0};
     	int *dist = new int[v+1]{0};
     	int *parent = new int[v+1];
 
     	for(int i=0;i<v;i++){
     		parent[i] = -1;
     	}
 
     	q.push(src);
     	visited[src] = true;
 
 
 
     	while(!q.empty()){
     		int node = q.front();
     		cout<<node<<" ";
     		q.pop();
 
     		for(int neighbour:adj[node]){
     			
     			if(!visited[neighbour]){
     				q.push(neighbour);
     				visited[neighbour] = true;
     				dist[neighbour] = dist[node]  + 1;
     				parent[neighbour] = node;
     			}
     		}
     	}
     	cout<<endl;
     	//Print the distances of every node from source
     	for(int i=0;i<v;i++){
     		//cout<<i<<"node having dist "<<dist[i]<<endl;
     	}
 
     	//cout<<"Shortest dist is "<<dist[dest]<<endl;
     	//cout<<"Shortest path is ";
 
     	int temp = dest;
     	while(temp!=-1){
     		cout<<temp<<"<--";
     		temp = parent[temp];
     	}
     }
 
     void dfsHelper(int src, map<int, bool> &visited) {
     	visited[src] = true;
     	cout<<src<<" ";
     	for(int neighbour : adj[src]) {
     		if(!visited[neighbour]) {
     			dfsHelper(neighbour, visited);
     		}
     	}
     }
 
     
 
     void dfs(int src) {
     	map<int, bool> visited;
     	dfsHelper(src, visited);
     }
 
     void dfsHelper2(int src, map<int, bool> &visited) {
     	visited[src] = true;
     	// cout<<src<<" ";
     	for(int neighbour : adj[src]) {
     		if(not visited[neighbour]) {
     			dfsHelper2(neighbour, visited);
     		}
     	}
     }
 
     int connectedComponents() {
     	map<int, bool> visited;
     	int component = 0;
     	for(int i=0;i<v;i++) {
     		int city = i;
     		if(!visited[i]) {
     			dfsHelper2(i, visited);
     			component++;
     		}
     	}
     	return component;
     }
};
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

//-------------TEMPLATE CLASSES ENDS--------
    
//-------------STRUCT NODE-----    
struct Node
{
    int x;
    int y;
    Node(int a=0, int b=0):x(a),y(b){};
};

//---------------CLASS NODE STARTS--------
class node{
public:
    ll id,a,l;
    vector<node*> v;
    set<node*> s;
    vector<pair<node*,ll>> vm;
    vector<edge<node*>*> ve;
    /////////////
    //ll d,h;
    // node* mr_img;
    // node* lf=NULL;
    // node* rt=NULL;
    node* prt=NULL;
    ///////////////
    ll ans =-1,vt = 0,tin=-1,low=-1;  
    node(ll x = 0,ll y =0){
        id=y,a=x,l=0;
        vm.clear(),v.clear(),ve.clear();
        ///////////
        //d=1,h=0;
        // mr_img=NULL;
        // lf=NULL;
        // rt=NULL;
        prt=NULL;
        ///////////////
        ans =1,vt = 0,tin=-1,low=-1;
    } 
    void adn(node* t){
        s.insert(t);
    }
    void cp(){
        for(auto &i:s)
            v.pb(i),l++;
    }
    void adn(node* t,ll w){
        edge<node*>* f= new edge<node*>(this,t,w);
        ve.pb(f),l++;
    }
    void adn(edge<node*>* t){
        ve.pb(t),l++;
    }
};
node* nnd(ll a=0,ll i=1){
    node* t = new node(a,i);
    return t;
}
node* nf(node* t,edge<node*>* f){
    return (f->a!=t)?f->a:f->b;
}
//---------CLASS NODE ENDS------------

//----------ALL FUNC'S dEFINED HERE-----
bool isPrime(int  x)
{   
	if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3; 
	for (int i = 5; i * i <= x; i += 6)
	{
		if (x % i == 0 || x % (i + 2) == 0) { return 0;}
	}
	return 1;
}

ll prime[1000002];

int Prime(int a)// FOR SINGLE TO KNOW FOR PRIME
{
    for(int i=2;i<=a/2;++i)
    {
        if(a%i==0)
        {
            return 0;
        }
    }
    return 1;
}

void sieve()// FOR PRIMES TILL A VALUE
{   for(int i=0;i<=1000001;i++)
    prime[i]=0;
    int maxn=1000001;
    for(int i=2;i<=maxn;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i;j<=maxn;j+=i)
            {
                prime[j]++;
            }
        }
    }
}
void fibo(ll a[],ll n)
{
    ll x=0;
    ll y=1;
    a[0]=0;
    a[1]=1;
    for(ll i=2;i<n;++i)
    {
        a[i]=(x+y)%10;
        x=y;
        y=a[i];
    }
}



ll power(ll x, ll n, ll p)
{
	ll y =abs(n);
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return n < 0 ? 1 / res : res;
}

//------------ALL PREDEFINED FUNC'S ENDS HERE--------
	
//----MAIN CODE STARTS HERE---------


void kardeshuru()
{	 
	 ll n;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    cin>>n;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    vector<ll> arr(n);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    for(ll i=0;i<n;i++){
        cin>>arr[i];kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
    ll cur=arr[0];kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    set<ll> s;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    s.insert(arr[0]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    bool flag=true;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    for(ll i=1;i<n;i++){
        if(arr[i]==cur){
            continue;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
        }
        else if(arr[i]>cur){
            auto x=s.upper_bound(cur);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            if(x==s.end()){
                s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            }
            else{
                if(*x<arr[i]){
                    flag=false;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                    break;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
                else{
                    s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
            }
        }
        else{
            auto x=s.lower_bound(cur);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            if(x==s.begin()){
                s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            }
            else{
                x--;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                if(*x>arr[i]){
                    flag=false;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                    break;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
                else{
                    s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
            }
        }
        cur=arr[i];kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
    if(flag){
        cout<<"YES"<<endl;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
    else{
        cout<<"NO"<<endl;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
}

//-----------HERE MAIN CODE ENDS-------------
signed main()
{

	fastio

/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	int t=1;
	cin>>t;
	
    while(t--)
    //FOR(i,1,t+1)
    {
        //cout<<"Case #"<<i<<": ";
 		kardeshuru();
    }
}

### Prompt

Please formulate a CPP solution to the following problem:

Uh oh! Ray lost his array yet again! However, Omkar might be able to help because he thinks he has found the OmkArray of Ray's array. The OmkArray of an array a with elements a_1, a_2, …, a_{2k-1}, is the array b with elements b_1, b_2, …, b_{k} such that b_i is equal to the median of a_1, a_2, …, a_{2i-1} for all i. Omkar has found an array b of size n (1 ≤ n ≤ 2 ⋅ 10^5, -10^9 ≤ b_i ≤ 10^9). Given this array b, Ray wants to test Omkar's claim and see if b actually is an OmkArray of some array a. Can you help Ray?

The median of a set of numbers a_1, a_2, …, a_{2i-1} is the number c_{i} where c_{1}, c_{2}, …, c_{2i-1} represents a_1, a_2, …, a_{2i-1} sorted in nondecreasing order. 

Input

Each test contains multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.

The first line of each test case contains an integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array b.

The second line contains n integers b_1, b_2, …, b_n (-10^9 ≤ b_i ≤ 10^9) — the elements of b.

It is guaranteed the sum of n across all test cases does not exceed 2 ⋅ 10^5. 

Output

For each test case, output one line containing YES if there exists an array a such that b_i is the median of a_1, a_2, ..., a_{2i-1} for all i, and NO otherwise. The case of letters in YES and NO do not matter (so yEs and No will also be accepted).

Examples

Input


5
4
6 2 1 3
1
4
5
4 -8 5 6 -7
2
3 3
4
2 1 2 3


Output


NO
YES
NO
YES
YES


Input


5
8
-8 2 -6 -5 -4 3 3 2
7
1 1 3 1 0 -2 -1
7
6 12 8 6 2 6 10
6
5 1 2 3 6 7
5
1 3 4 3 0


Output


NO
YES
NO
NO
NO

Note

In the second case of the first sample, the array [4] will generate an OmkArray of [4], as the median of the first element is 4.

In the fourth case of the first sample, the array [3, 2, 5] will generate an OmkArray of [3, 3], as the median of 3 is 3 and the median of 2, 3, 5 is 3.

In the fifth case of the first sample, the array [2, 1, 0, 3, 4, 4, 3] will generate an OmkArray of [2, 1, 2, 3] as 

  * the median of 2 is 2 
  * the median of 0, 1, 2 is 1 
  * the median of 0, 1, 2, 3, 4 is 2 
  * and the median of 0, 1, 2, 3, 3, 4, 4 is 3. 



In the second case of the second sample, the array [1, 0, 4, 3, 5, -2, -2, -2, -4, -3, -4, -1, 5] will generate an OmkArray of [1, 1, 3, 1, 0, -2, -1], as 

  * the median of 1 is 1 
  * the median of 0, 1, 4 is 1 
  * the median of 0, 1, 3, 4, 5 is 3 
  * the median of -2, -2, 0, 1, 3, 4, 5 is 1 
  * the median of -4, -2, -2, -2, 0, 1, 3, 4, 5 is 0 
  * the median of -4, -4, -3, -2, -2, -2, 0, 1, 3, 4, 5 is -2 
  * and the median of -4, -4, -3, -2, -2, -2, -1, 0, 1, 3, 4, 5, 5 is -1 



For all cases where the answer is NO, it can be proven that it is impossible to find an array a such that b is the OmkArray of a.

### Response

```cpp
// KEDOS123

#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define all(a) a.begin(),a.end()
#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ROF(i, a, b) for (int i = b; i >= a;i--)
#define minheap(a) priority_queue <a, vector<a>, greater<a> >
#define maxheap(a) priority_queue<a> 
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define vd vector<double>
#define vs vector<string>\
#define ms(x,y) memset(x,y,sizeof(x))
#define umap unordered_map<int,int>
#define lb lower_bound
#define ub upper_bound
//#define nx cout<<"\n";
#define INF 1000000000000000000
#define inf 1000000000
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define PI 3.14159265
#define pl pair<ll,ll> 
#define int long long
#define V vector
#define CIN(x) do { \
        assert(!cin.eof()); \
        cin >> x; \
        assert(!cin.fail()); \
} while(0);
#if DEBUG
#define debug_print(...) _debug_print(__VA_ARGS__)
#define debug_printf(...) printf(__VA_ARGS__)
#define debug_print_time _debug_print_time
#else // DEBUG
#define debug_print(...)
#define debug_printf(...)
#define debug_print_time
#endif // DEBUG
 //#define MOD   
#define EPS 1e-9
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define double long double
#define f(a,b,c) for(int a=b;a<=c;a++)
#define fd(a,b,c) for(int a=b;a>=c;a--)
const int MOD = 1000000007;


typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef double ld;
typedef vector<pii> vii;

typedef tuple<ll, ll> t2;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

//global varibles
ll bb=0, vikings=0;
ll kedos=0,jai=0;
//-----------INLINE FUNC---------
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}
inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}
inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}
inline void wri(const int v) { cout << v; }
inline void wrll(const long long &v) { cout << v; }
inline void wrs(const string& s) { cout << s; }
inline void wrc(const char c) { cout << c; }

//----------Template classes-------
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<class T>
void wrv(T beg_iter, T end_iter, string separator = " ", string end_of_line = "\n") {
    for (; beg_iter != end_iter; ++beg_iter) {
        cout << *beg_iter;
        cout << separator;
    }
    cout << end_of_line;
}

template <typename TT, typename T>
void incr_m(map<TT, T> &m, TT k)
{
    if (m.find(k) == m.end()) m[k] = 0;
    m[k]++;
}
 
void llin(ll &a)
{
    CIN(a);
}
 
void llinl1(vll &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a;
        CIN(a);
        v.push_back(a);
    }
}
 
void llinl2(V<t2> &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a, b;
        CIN(a >> b);
        v.push_back(t2(a, b));
    }
}
 
void llinl3(V<t3> &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a, b, c;
        CIN(a >> b >> c);
        v.push_back(t3(a, b, c));
    }
}
 
void llinl4(V<t4> &v, ll count)
{
    for (ll i = 0LL; i < count; ++i) {
        ll a, b, c, d;
        CIN(a >> b >> c >> d);
        v.push_back(t4(a, b, c, d));
    }
}
 
void llina(V<ll> &v, ll count)
{
    llinl1(v, count);
}
 
template <typename T>
void sort(V<T> &v)
{
    sort(v.begin(), v.end());
}
 
template <typename T>
void sort_reverse(V<T> &v)
{
    sort(v.begin(), v.end(), greater<T>());
}
 
t2 _ext_gcd(ll a, ll b, ll g)
{
    if (!b) return t2(1, 0);
    ll q = a / b;
    ll r = a % b;
    t2 sol = _ext_gcd(b, r, g);
    ll sx = get<0>(sol);
    ll sy = get<1>(sol);
    ll x = sy;
    ll y = sx - q * sy;
    return t2(x, y);
}
 
t2 ext_gcd(ll a, ll b)
{
    return _ext_gcd(a, b, gcd(a, b));
}
 
// x and mod must be coprime
ll mod_inv(ll x, ll mod)
{
    t2 result = ext_gcd(x, mod);
    ll ret = get<0>(result);
    while (ret < 0) ret += mod;
    ret %= mod;
    return ret;
}
 
template <typename T>
void _debug_print(T x)
{
    cout << x << " ";
}
 
void _debug_print(const t2 &x)
{
    ll x1 = get<0>(x);
    ll x2 = get<1>(x);
    cout << "(" << x1 << ", " << x2 << ") ";
}
 
void _debug_print(const t3 &x)
{
    ll x1 = get<0>(x);
    ll x2 = get<1>(x);
    ll x3 = get<2>(x);
    cout << "(" << x1 << ", " << x2 << ", " << x3 << ") ";
}
 
void _debug_print(const t4 &x)
{
    ll x1 = get<0>(x);
    ll x2 = get<1>(x);
    ll x3 = get<2>(x);
    ll x4 = get<3>(x);
    cout << "(" << x1 << ", " << x2 << ", " << x3 << ", " << x4 << ") ";
}
 
template <typename T>
void _debug_print(T xarray[], ll n)
{
    FOR (i,0, n) _debug_print(xarray[i]);
    cout << endl;
}
 
template <typename T>
void _debug_print(const V<T> &xlist)
{
    for (auto x : xlist) _debug_print(x);
    cout << endl;
}
 
template <typename T>
void _debug_print(const set<T> &xset)
{
    for (auto x : xset) _debug_print(x);
    cout << endl;
}
 
template <typename TT, typename T>
void _debug_print(const map<TT, T> &xlist)
{
    for (auto x : xlist) {
        TT k = x.first;
        T v = x.second;
        cout << "K=";
        _debug_print(k);
        cout << " V=";
        _debug_print(v);
        cout << endl;
    }
}

struct lex_compare {
    public:
    bool operator() (const pl& lhs, const pl& rhs) const {
        return (lhs.se>rhs.se);
    }
};
template<class T>
class edge{
    public:
        T a,b;
        ll x;
        edge(){
            a=NULL,b=NULL,x=-1;
        }
        edge(T a,T b,ll x){
            this->a=a,this->b=b,this->x=x;
        }
    };
    const int mod=1e9+7;
template<const int MOD>
struct modular_int{
	int x;
	static vector<int> inverse_list ;
	const static int inverse_limit;
	const static bool is_prime;
	modular_int(){
		x = 0;
	}
	template<typename T>  
	modular_int(const T z){
		x = (z%MOD);
		if (x < 0) x += MOD; 	
	}
	modular_int(const modular_int<MOD>* z){
		x = z->x;
	}
	modular_int(const modular_int<MOD>& z){
		x = z.x;
	}
	modular_int operator - (const modular_int<MOD>& m) const{
		modular_int<MOD> U;
		U.x = x - m.x;
		if (U.x < 0) U.x += MOD;
		return U;
	}
	modular_int operator + (const modular_int<MOD>& m) const{
		modular_int<MOD> U;
		U.x = x + m.x;
		if (U.x >= MOD) U.x -= MOD;
		return U;
	}
	modular_int& operator -= (const modular_int<MOD>& m){
		x -= m.x;
		if (x < 0) x += MOD;
		return *this;
	}	
	modular_int& operator += (const modular_int<MOD>& m){
		x += m.x;
		if (x >= MOD) x -= MOD;
		return *this;
	}	
	modular_int operator * (const modular_int<MOD>& m) const{
		modular_int<MOD> U;
		U.x = (x* 1ull * m.x) %MOD;
		return U;
	}
	modular_int& operator *= (const modular_int<MOD>& m){
		x = (x * 1ull * m.x)%MOD;
		return *this;
	}
	template<typename T>
	friend modular_int operator + (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) + p);
	}
	template<typename T>
	friend modular_int operator - (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) - p);
	}
	template<typename T>
	friend modular_int operator * (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) * p);
	}
	template<typename T>
	friend modular_int operator / (const T &l, const modular_int<MOD>& p){
		return (modular_int<MOD>(l) / p);
	}
 
	int value() const{
		return x;
	}
 
	modular_int operator ^ (const modular_int<MOD>& cpower) const{
		modular_int<MOD> ans;
		ans.x = 1;
		modular_int<MOD> curr(this);
		int power = cpower.x;
 
		if (curr.x <= 1){
			if (power == 0) curr.x = 1;
			return curr;
		}
		while( power > 0){
			if (power&1){
				ans *= curr;
			}
			power >>= 1;
			if (power) curr *= curr;
		}
		return ans;
	}
 
 
	modular_int operator ^ (long long power) const{
		modular_int<MOD> ans;
		ans.x = 1;
		modular_int<MOD> curr(this);
		if (curr.x <= 1){
			if (power == 0) curr.x = 1;
			return curr;
		}
		// Prime Mods
		if (power >= MOD && is_prime){
			power %= (MOD - 1);
		}
 
		while( power > 0){
			if (power&1){
				ans *= curr;
			}
			power >>= 1;
			if (power) curr *= curr;
 
		}
		return ans;
	}
	
	template<typename T>
	modular_int& operator ^= (T power) {
		modular_int<MOD> res = (*this)^power;
		x = res.x;
		return *this;
	}
 
 
	template<typename T>
	modular_int pow(T x){
		return (*this)^x;
	}
 
	
	pair<long long,long long> gcd(const int a, const int b) const {
		if (b==0) return {1,0}; 
		pair<long long,long long> c = gcd(b , a%b);
		return { c.second , c.first - (a/b)*c.second}; 
	}
 
	inline void init_inverse_list() const {
		
		vector<int>& dp = modular_int<MOD>::inverse_list;
		dp.resize(modular_int<MOD>::inverse_limit + 1);
		int n = modular_int<MOD>::inverse_limit;
		dp[0] = 1;
		if (n > 1) dp[1] = 1;
		for(int i = 2; i <= n; ++i){
			dp[i] = (dp[MOD%i] * 1ull *(MOD - MOD/i))%MOD;
		}
	
	}
	modular_int<MOD> get_inv() const {
		if (modular_int<MOD>::inverse_list.size() < modular_int<MOD>::inverse_limit + 1) init_inverse_list();
 
		if (this->x <= modular_int<MOD>::inverse_limit){
			return modular_int<MOD>::inverse_list[this->x];
		}
		pair<long long,long long> G = gcd(this->x,MOD);
		return modular_int<MOD>(G.first);
	}
	modular_int<MOD> operator - () const {
		modular_int<MOD> v(0);
		v -= (*this);
		return v;
	}
	modular_int operator / (const modular_int<MOD>& m) const{
		modular_int<MOD> U(this);
		U *= m.get_inv();
		return U;
	}
	modular_int& operator /= (const modular_int<MOD>& m){
		(*this) *= m.get_inv();
		return *this;
	}
	bool operator==(const modular_int<MOD>& m) const{
		return x == m.x;
	}
 
	bool operator < (const modular_int<MOD>& m) const {
		return x < m.x;
	}
 
 
	template<typename T>
	bool operator == (const T& m) const{
		return (*this)== (modular_int<MOD>(m));
	}
 
	template<typename T>
	bool operator < (const T& m) const {
		return x < (modular_int<MOD>(m)).x;
	}
	template<typename T>
	bool operator > (const T& m) const {
		return x > (modular_int<MOD>(m)).x;
	}
	template<typename T>
	friend bool operator == (const T& x, const modular_int<MOD>& m) {
		return (modular_int<MOD>(x)).x == m.x;
	}
	template<typename T> 
	friend bool operator < (const T& x, const modular_int<MOD>& m){
		return (modular_int<MOD>(x)).x < m.x;
	}
	template<typename T> 
	friend bool operator > (const T& x, const modular_int<MOD>& m){
		return (modular_int<MOD>(x)).x > m.x;
	}
 
	friend istream& operator >> (istream& is, modular_int<MOD>& p){
		int64_t val;
		is >> val;
		p.x = (val%MOD);
		if (p.x < 0) p.x += MOD;
		return is;
	}
	friend ostream& operator << (ostream& os, const modular_int<MOD>& p) {return os<<p.x;}
 
 
 
};
 
 
 
using mint = modular_int<mod>;
template<const int MOD>
vector<int> modular_int<MOD>::inverse_list ;
template<const int MOD>
const int modular_int<MOD>::inverse_limit = -1;
template<const int MOD>
const bool modular_int<MOD>::is_prime = true; 
// template<>   //-> useful if computing inverse fact = i_f[i-1] / i;
// const int modular_int<mod>::inverse_limit = 100000;

/*/---------------------------Graph---------------------/*/
template<typename T>
class Graph {
	int v;
	list<int> *adj;
 
public:
	Graph(int v) {
		this->v = v;
		adj = new list<int>[v];
	}
 
	void addEdge(int u, int v, bool bidir = true) {
		adj[u].push_back(v);
		if(bidir) {
			adj[v].push_back(u);
		}
	}
 
	void printAdjList() {
		for(int i=0;i<this->v;i++) {
			cout<<i<<"->";
			for(int node:adj[i]) {
				cout<<node<<", ";
			}
			cout<<endl;
		}
	}
 
	void bfs(int src) {
		queue<int> q;
		bool *visited = new bool[this->v+1]{0};
 
		q.push(src);
		visited[src] = true;
 
		while(!q.empty()) {
			int node = q.front();
			cout<<node<<" ";
			q.pop();
			for(int neighbour: adj[node]) {
				if(!visited[neighbour]) {
					q.push(neighbour);
					visited[neighbour] = true;
				}
			}
		}
 
		delete [] visited;
	}
 
 
	void bfs(int src,int dest){
     	//Traverse all the nodes of the graph
     	queue<int> q;
     	bool *visited = new bool[v+1]{0};
     	int *dist = new int[v+1]{0};
     	int *parent = new int[v+1];
 
     	for(int i=0;i<v;i++){
     		parent[i] = -1;
     	}
 
     	q.push(src);
     	visited[src] = true;
 
 
 
     	while(!q.empty()){
     		int node = q.front();
     		cout<<node<<" ";
     		q.pop();
 
     		for(int neighbour:adj[node]){
     			
     			if(!visited[neighbour]){
     				q.push(neighbour);
     				visited[neighbour] = true;
     				dist[neighbour] = dist[node]  + 1;
     				parent[neighbour] = node;
     			}
     		}
     	}
     	cout<<endl;
     	//Print the distances of every node from source
     	for(int i=0;i<v;i++){
     		//cout<<i<<"node having dist "<<dist[i]<<endl;
     	}
 
     	//cout<<"Shortest dist is "<<dist[dest]<<endl;
     	//cout<<"Shortest path is ";
 
     	int temp = dest;
     	while(temp!=-1){
     		cout<<temp<<"<--";
     		temp = parent[temp];
     	}
     }
 
     void dfsHelper(int src, map<int, bool> &visited) {
     	visited[src] = true;
     	cout<<src<<" ";
     	for(int neighbour : adj[src]) {
     		if(!visited[neighbour]) {
     			dfsHelper(neighbour, visited);
     		}
     	}
     }
 
     
 
     void dfs(int src) {
     	map<int, bool> visited;
     	dfsHelper(src, visited);
     }
 
     void dfsHelper2(int src, map<int, bool> &visited) {
     	visited[src] = true;
     	// cout<<src<<" ";
     	for(int neighbour : adj[src]) {
     		if(not visited[neighbour]) {
     			dfsHelper2(neighbour, visited);
     		}
     	}
     }
 
     int connectedComponents() {
     	map<int, bool> visited;
     	int component = 0;
     	for(int i=0;i<v;i++) {
     		int city = i;
     		if(!visited[i]) {
     			dfsHelper2(i, visited);
     			component++;
     		}
     	}
     	return component;
     }
};
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

//-------------TEMPLATE CLASSES ENDS--------
    
//-------------STRUCT NODE-----    
struct Node
{
    int x;
    int y;
    Node(int a=0, int b=0):x(a),y(b){};
};

//---------------CLASS NODE STARTS--------
class node{
public:
    ll id,a,l;
    vector<node*> v;
    set<node*> s;
    vector<pair<node*,ll>> vm;
    vector<edge<node*>*> ve;
    /////////////
    //ll d,h;
    // node* mr_img;
    // node* lf=NULL;
    // node* rt=NULL;
    node* prt=NULL;
    ///////////////
    ll ans =-1,vt = 0,tin=-1,low=-1;  
    node(ll x = 0,ll y =0){
        id=y,a=x,l=0;
        vm.clear(),v.clear(),ve.clear();
        ///////////
        //d=1,h=0;
        // mr_img=NULL;
        // lf=NULL;
        // rt=NULL;
        prt=NULL;
        ///////////////
        ans =1,vt = 0,tin=-1,low=-1;
    } 
    void adn(node* t){
        s.insert(t);
    }
    void cp(){
        for(auto &i:s)
            v.pb(i),l++;
    }
    void adn(node* t,ll w){
        edge<node*>* f= new edge<node*>(this,t,w);
        ve.pb(f),l++;
    }
    void adn(edge<node*>* t){
        ve.pb(t),l++;
    }
};
node* nnd(ll a=0,ll i=1){
    node* t = new node(a,i);
    return t;
}
node* nf(node* t,edge<node*>* f){
    return (f->a!=t)?f->a:f->b;
}
//---------CLASS NODE ENDS------------

//----------ALL FUNC'S dEFINED HERE-----
bool isPrime(int  x)
{   
	if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3; 
	for (int i = 5; i * i <= x; i += 6)
	{
		if (x % i == 0 || x % (i + 2) == 0) { return 0;}
	}
	return 1;
}

ll prime[1000002];

int Prime(int a)// FOR SINGLE TO KNOW FOR PRIME
{
    for(int i=2;i<=a/2;++i)
    {
        if(a%i==0)
        {
            return 0;
        }
    }
    return 1;
}

void sieve()// FOR PRIMES TILL A VALUE
{   for(int i=0;i<=1000001;i++)
    prime[i]=0;
    int maxn=1000001;
    for(int i=2;i<=maxn;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i;j<=maxn;j+=i)
            {
                prime[j]++;
            }
        }
    }
}
void fibo(ll a[],ll n)
{
    ll x=0;
    ll y=1;
    a[0]=0;
    a[1]=1;
    for(ll i=2;i<n;++i)
    {
        a[i]=(x+y)%10;
        x=y;
        y=a[i];
    }
}



ll power(ll x, ll n, ll p)
{
	ll y =abs(n);
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return n < 0 ? 1 / res : res;
}

//------------ALL PREDEFINED FUNC'S ENDS HERE--------
	
//----MAIN CODE STARTS HERE---------


void kardeshuru()
{	 
	 ll n;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    cin>>n;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    vector<ll> arr(n);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    for(ll i=0;i<n;i++){
        cin>>arr[i];kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
    ll cur=arr[0];kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    set<ll> s;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    s.insert(arr[0]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    bool flag=true;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    for(ll i=1;i<n;i++){
        if(arr[i]==cur){
            continue;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
        }
        else if(arr[i]>cur){
            auto x=s.upper_bound(cur);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            if(x==s.end()){
                s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            }
            else{
                if(*x<arr[i]){
                    flag=false;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                    break;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
                else{
                    s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
            }
        }
        else{
            auto x=s.lower_bound(cur);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            if(x==s.begin()){
                s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
            }
            else{
                x--;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                if(*x>arr[i]){
                    flag=false;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                    break;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
                else{
                    s.insert(arr[i]);kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
                }
            }
        }
        cur=arr[i];kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
    if(flag){
        cout<<"YES"<<endl;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
    else{
        cout<<"NO"<<endl;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;
jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;
jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
    }
}

//-----------HERE MAIN CODE ENDS-------------
signed main()
{

	fastio

/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	int t=1;
	cin>>t;
	
    while(t--)
    //FOR(i,1,t+1)
    {
        //cout<<"Case #"<<i<<": ";
 		kardeshuru();
    }
}

```