#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, a[200001], t, n, r, s;
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    k = 0;
    r = 0;
    for (i = 0; i < n - 1; i++) {
      if (a[i + 1] < a[i]) {
        k++;
      }
    }
    if (k == n - 1) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
