#include <bits/stdc++.h>
using namespace std;
const int maxnn = 1e6 + 7;
const int maxn = 1e6 + 7;
const int inf = 1e9 + 7;
const long long mod = 1e9 + 7;
inline int read() {
  int X = 0;
  bool flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    X = (X << 1) + (X << 3) + ch - '0';
    ch = getchar();
  }
  if (flag) return X;
  return ~(X - 1);
}
inline int write(int X) {
  if (X < 0) {
    putchar('-');
    X = ~(X - 1);
  }
  int s[20], top = 0;
  while (X) {
    s[++top] = X % 10;
    X /= 10;
  }
  if (!top) s[++top] = 0;
  while (top) putchar(s[top--] + '0');
}
int a[maxnn];
int main() {
  int tot = read();
  while (tot--) {
    int n = read();
    for (int i = 1; i <= n; ++i) {
      a[i] = read();
    }
    int flag = 0;
    for (int i = 2; i <= n; ++i) {
      if (a[i] < a[i - 1])
        continue;
      else {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      printf("NO\n");
    } else {
      printf("YES\n");
    }
  }
  return 0;
}
