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