#include<bits/stdc++.h>
#define ll int
#define ff first
#define ss second
#define mkp make_pair
#define pb push_back
using namespace std;
#pragma GCC optimize("O3","Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,tune=native")
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+2],b[n+2];
        for(ll i=1; i<=n; i++)
        {
            cin>>a[i];
            b[i]=a[i];
        }
        sort(b+1,b+n+1);
        while(true)
        {
         bool t2=1,t3=1;
         for(ll i=2; i<n; i++)
         {
             if(b[i-1]+b[i+1]<2*b[i]){t2=0; break;}
         }
         if(t2){cout<<"YES\n"; break;}
         next_permutation(b+1,b+n+1);
         for(ll i=1; i<=n; i++)
         {
             if(a[i]!=b[i]){t3=0; break;}
         }
         if(t3){cout<<"NO\n"; break;}
        }
    }

}

