#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*char* readline();
char** split_string(char*);

/*
 * Complete the canModify function below.
 */

/*
 * Please either make the string static or allocate on the heap. For example,
 * static char str[] = "hello world";
 * return str;
 *
 * OR
 *
 * char* str = "hello world";
 * return str;
 *
 */
/*char* canModify(int a_count, int* a) {
    /*
     * Write your code here.
     */

//}

/*int main()
{
    FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w");

    char* n_endptr;
    char* n_str = readline();
    int n = strtol(n_str, &n_endptr, 10);

    if (n_endptr == n_str || *n_endptr != '\0') { exit(EXIT_FAILURE); }

    char** a_temp = split_string(readline());

    int a[n];

    for (int a_itr = 0; a_itr < n; a_itr++) {
        char* a_item_endptr;
        char* a_item_str = a_temp[a_itr];
        int a_item = strtol(a_item_str, &a_item_endptr, 10);

        if (a_item_endptr == a_item_str || *a_item_endptr != '\0') { exit(EXIT_FAILURE); }

        a[a_itr] = a_item;
    }

    char* result = canModify(a_count, a);

    fprintf(fptr, "%s\n", result);

    fclose(fptr);

    return 0;
}

char* readline() {
    size_t alloc_length = 1024;
    size_t data_length = 0;
    char* data = malloc(alloc_length);

    while (true) {
        char* cursor = data + data_length;
        char* line = fgets(cursor, alloc_length - data_length, stdin);

        if (!line) { break; }

        data_length += strlen(cursor);

        if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; }

        size_t new_length = alloc_length << 1;
        data = realloc(data, new_length);

        if (!data) { break; }

        alloc_length = new_length;
    }

    if (data[data_length - 1] == '\n') {
        data[data_length - 1] = '\0';
    }

    data = realloc(data, data_length);

    return data;
}

char** split_string(char* str) {
    char** splits = NULL;
    char* token = strtok(str, " ");

    int spaces = 0;

    while (token) {
        splits = realloc(splits, sizeof(char*) * ++spaces);
        if (!splits) {
            return splits;
        }

        splits[spaces - 1] = token;

        token = strtok(NULL, " ");
    }

    return splits;
}*/
void Sort(int a[],int , int);

int  main()
{
    int t;
    scanf("%d",&t);
    int n,a[100],b[100],i,j,c=0,temp;
while(t--)
{
    scanf("%d",&n);
  for(i=0;i<n;i++)
  {
      scanf("%d",&a[i]);
      
  }
     for(i=0;i<n;i++)
  {
     b[i]=a[i];
      
  }
    Sort(b,n,1);
    
    for(i=0;i<n;i++)
    {
     if(a[i]!=b[i])   
     {
         c++;
         i++;
     }
    }
   // printf(" %d",c);
    if(c==1)
        printf("YES\n");
    else 
        printf("NO\n");
}
    return 0;
}
    void Sort(int a[], int n, int gap)     /* same for shell sort*/
{
    int i, j, temp;
        for(i = gap; i < n; i++)
        {
            for(j = i; j >= gap && a[j]<a[j-gap]; j =j- gap)
            {
              	temp = a[j];
              	a[j]=a[j-1];
              	a[j-1]=temp;			    
            }
        }
     //   return 0;
}