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

using ll= long long;

//bool equals(ll a, ll b, ll a1, ll b1) {
//    if (a==a1 || a==b1 || b==a1 || b==b1) return true;
//    return false;
//}

int factorial(int n) {
    if(n==1) return 1;
    return n * factorial(n-1);
}
void permutations1(vector<int>& arr, vector<vector<int>>& permutations, vector<int> permutation, int n, map<int, int> permutation_check) {
    if (permutation.size() == n) {
        permutations.push_back(permutation);
    }
    else {
        for (int i = 0; i < n;i++) {
            if (permutation_check.count(arr[i]))continue;
            permutation.push_back(arr[i]);
            permutation_check.insert({arr[i], 1});
            permutations1(arr, permutations, permutation, n, permutation_check);
            permutation_check.erase(arr[i]);
            permutation.pop_back();
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << factorial(7);
    ll t;
    cin>>t;
    for (ll i = 0;i< t;i++) {
        int n;
        cin>>n;
        vector<int> arr(n);
        vector<vector<int>> permutations;
        vector<int> permutation;
        map<int,int> permutation_check;
        for(int j = 0; j < n;j++) {
            cin>>arr[j];
        }
        permutations1(arr, permutations, permutation, n, permutation_check);
        bool g = false;
        for (int j = 0; j < permutations.size();j++) {
            bool is_good = true;
            for (int k = 1; k < permutations[j].size()-1;k++) {
                if (permutations[j][k-1]+permutations[j][k+1]>=2*permutations[j][k]) continue;
                is_good=false;
                break;
            }
            if (is_good) {
                cout << "YES" << endl;
                g=true;
                break;
            }

        }
        if (g) continue;
        cout << "NO" << endl;

    }
    return 0;
}
