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