#include <bits/stdc++.h>
using namespace std;
int t;
long long n, a;
long long ans;
int tree[50005];
void update(int x) {
  while (x <= n) {
    tree[x]++;
    x += ((x) & -(x));
  }
}
long long sum(int x) {
  long long tot = 0;
  while (x > 0) {
    tot += tree[x];
    x -= ((x) & -(x));
  }
  return tot;
}
struct node {
  int val;
  int num;
} e[50005];
bool cmp(node x, node y) {
  if (x.val == y.val)
    return x.num < y.num;
  else
    return x.val < y.val;
}
int main() {
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    memset(tree, 0, sizeof(tree));
    scanf("%d", &n);
    for (int j = 1; j <= n; j++) {
      scanf("%d", &e[j].val);
      e[j].num = j;
    }
    sort(e + 1, e + n + 1, cmp);
    ans = 0;
    for (int j = 1; j <= n; j++) {
      update(e[j].num);
      ans += (j - sum(e[j].num));
    }
    if (ans <= (n * (n - 1)) / 2 - 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
