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