#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  long long int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int c = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] < arr[i - 1]) c++;
  }
  if (c == n)
    cout << "NO"
         << "\n";
  else
    cout << "YES"
         << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
