#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long flag = 0;
    long long *a = new long long[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n - 1; i++) {
      if (a[i] <= a[i + 1]) {
        flag = 1;
        break;
      }
    }
    if (n == 1)
      cout << "YES\n";
    else {
      if (flag == 1)
        cout << "YES\n";
      else
        cout << "NO\n";
    }
  }
}
