#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (a == 0) return 0;
  if (b == 0) return 1;
  if (b == 1) return a;
  long long small = power(a, b / 2);
  if (b % 2 == 0) return small * small;
  return small * small * a;
}
int _mergeSort(vector<long long> &arr, int temp[], int left, int right);
int merge(vector<long long> &arr, int temp[], int left, int mid, int right);
int mergeSort(vector<long long> &arr, int array_size) {
  int temp[array_size];
  return _mergeSort(arr, temp, 0, array_size - 1);
}
int _mergeSort(vector<long long> &arr, int temp[], int left, int right) {
  int mid, inv_count = 0;
  if (right > left) {
    mid = (right + left) / 2;
    inv_count += _mergeSort(arr, temp, left, mid);
    inv_count += _mergeSort(arr, temp, mid + 1, right);
    inv_count += merge(arr, temp, left, mid + 1, right);
  }
  return inv_count;
}
int merge(vector<long long> &arr, int temp[], int left, int mid, int right) {
  int i, j, k;
  int inv_count = 0;
  i = left;
  j = mid;
  k = left;
  while ((i <= mid - 1) && (j <= right)) {
    if (arr[i] <= arr[j]) {
      temp[k++] = arr[i++];
    } else {
      temp[k++] = arr[j++];
      inv_count = inv_count + (mid - i);
    }
  }
  while (i <= mid - 1) temp[k++] = arr[i++];
  while (j <= right) temp[k++] = arr[j++];
  for (i = left; i <= right; i++) arr[i] = temp[i];
  return inv_count;
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int count = mergeSort(a, n);
    if (count <= ((n * (n - 1)) / 2 - 1)) {
      cout << "YES\n";
      continue;
    }
    cout << "NO\n";
  }
}
