#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, a, b, exch;
  vector<string> res;
  vector<unsigned int> aux1;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n;
    aux1.clear();
    for (int j = 0; j < n; j++) {
      cin >> a;
      aux1.push_back(a);
    }
    exch = 0;
    for (int j = 0; j < n - 1; j++) {
      exch += (aux1[j] <= aux1[j + 1]) ? 0 : 1;
    }
    if (exch == n - 1)
      res.push_back("NO");
    else
      res.push_back("YES");
  }
  for (int i = 0; i < res.size(); i++) cout << res[i] << endl;
  return 0;
}
