#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x > y ? y : x; }
bool cmp(long long x, long long y) { return x > y; }
long long gcd(long long x, long long y) { return (y == 0) ? x : gcd(y, x % y); }
template <typename T>
void read(T& x) {
  int ch = getchar();
  x = 0;
  bool f = false;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    f = true;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  if (f) x = -x;
}
long long a[50005] = {0};
int main() {
  long long n = 0, m = 0, t = 0;
  long long i = 0, j = 0, k = 0;
  read(t);
  while (t--) {
    read(n);
    m = 0;
    for (i = 1; i <= n; i++) {
      read(a[i]);
      if (i >= 2) {
        if (a[i] < a[i - 1]) m++;
      }
    }
    if (m == n - 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
