#include <iostream>
#include <cmath>
#include <vector>
#include <ios>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#define lol long long
#define mp(x,y) make_pair(x,y)
//#define LIM 9999999
using namespace std;

//const lol mod=1e9+7;

/*  author: H3XoRuSH  */

int main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol T,n;
    cin >> T;
    while(T--){
        cin >> n;
        lol x[n];
        for(lol i=0; i<n; i++){
            cin >> x[i];
        }
        vector<lol> y(n,1);
        lol yeah=0;
        for(lol i=1; i<n; i++){
            for(lol j=0; j<i; j++){
                if(x[i]>=x[j]) y[i]=max(y[i],y[j]+1);
                yeah=max(yeah,y[i]);
            }
            yeah=max(yeah,y[i]);
        }
        lol c=n-yeah;
        if(c<=1) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}