#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
long long a[maxn], cnt;
void merge(long long L, long long M, long long R) {
  const long long Sizeof_Left = M - L + 1, Sizeof_Right = R - M;
  long long left[Sizeof_Left], right[Sizeof_Right];
  for (int i = L; i <= M; ++i) left[i - L] = a[i];
  for (int i = M + 1; i <= R; ++i) right[i - M - 1] = a[i];
  long long i = 0, j = 0, k = L;
  while (i < Sizeof_Left && j < Sizeof_Right) {
    if (left[i] <= right[j]) {
      a[k] = left[i];
      i++, k++;
    } else {
      a[k] = right[j];
      j++, k++;
      cnt += M - i + 1 - L;
    }
  }
  while (i < Sizeof_Left) a[k++] = left[i++];
  while (j < Sizeof_Right) a[k++] = right[j++];
}
void mergesort(long long L, long long R) {
  if (L == R) return;
  long long M = (L + R) / 2;
  mergesort(L, M);
  mergesort(M + 1, R);
  merge(L, M, R);
}
int main() {
  long long t;
  scanf("%lld", &t);
  while (t--) {
    cnt = 0;
    long long n;
    scanf("%lld", &n);
    for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
    mergesort(1, n);
    if (cnt > (n * (n - 1)) / 2 - 1)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
