#include <bits/stdc++.h>
using namespace std;
bool compare(int s, int z) { return s > z; }
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v, v1;
    set<int> s;
    s.clear();
    bool flag = false;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      if (s.count(x)) {
        flag = true;
      } else
        s.insert(x);
      v.push_back(x);
      v1.push_back(x);
    }
    if (flag == true) {
      cout << "YES" << endl;
      continue;
    }
    sort(v.begin(), v.end(), compare);
    if (v == v1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
