#include <iostream>
#include <stdio.h>
#define FOR(i,a,b) for (int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define REP(i,b) for (int i=0; i<b; ++i)
#define input stdin
#define output stdout
#define assign freopen
#define endl '\n'
#define sz(x) (int) x.size()
#define div /
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
typedef long long int64;
typedef unsigned long long qword;
typedef void procedure;
using namespace std;
int n;
int a[25],b[25];
procedure Input()
{
    cin >> n;
    FOR(i,1,n)
        cin >> a[i];
}
bool check()
{
    FOR(i,1,n-1)
        if (b[i]>b[i+1]) return false;
    return true;
}
procedure Solve()
{
    b[n+1]=5000;
    b[0]=0;
    FOR(i,1,n) {
        FOR(j,1,n)
            b[j]=a[j];
        b[i]=b[i-1];
        if (check()) {
            cout << "YES";
            return;
        }
        b[i]=b[i+1];
        if (check()) {
            cout << "YES";
            return;
        }
    }
    cout << "NO";
}
int main()
{
    //assign("input.txt","r",input);
    //assign("output.txt","w",output);
    iostream::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    FOR(i,1,t) {
        Input();
        Solve();
        cout << endl;
    }
    return 0;
}