#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long int> a(n), b(n);
    map<long long int, bool> mp;
    bool ok = false;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i];
      if (mp[a[i]]) {
        ok = true;
      }
      mp[a[i]] = true;
    }
    sort(b.rbegin(), b.rend());
    if (a != b) {
      ok = true;
    }
    if (ok) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
