#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define forin for(int i = 1; i <= n; i++)
#define forch(j, k) for(int i = j; i <= k; i++)
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
const lol N = 3e5+10;
lol t, n, a[N], nf, f;
void solve() {
    cin >> n;
    forin cin >> a[i];
    nf = 1;
    forin nf *= i;
    forch(1, nf) {
        f = 1;
        for(int j = 2; j < n; j++) if(a[j-1]+a[j+1] < 2*a[j]) {f = 0; break;}
        if(f) {Yes; return;}
        next_permutation(a+1,a+1+n);
    }
    No;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> t;
    while(t--) solve();
}