#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];
    int cnt = 0;
    for (int i = 1; i < n; i++) {
      if (vec[i - 1] > vec[i])
        cnt++;
      else
        break;
    }
    if (cnt == n - 1)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
}
