#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    long long int temp[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      temp[i] = a[i];
    }
    set<long long int> s(temp, temp + n);
    sort(a, a + n, greater<long long int>());
    bool flag = false;
    for (long long int i = 0; i < n; i++) {
      if (a[i] != temp[i]) {
        flag = true;
      }
    }
    if (flag || s.size() < n)
      cout << "YES\n";
    else {
      cout << "NO\n";
    }
  }
  return 0;
}
